This topic describes how you can configure the xamGantt™'s context menus and add additional context menus for predefined areas of the xamGantt control.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
The xamGantt control comes with a set of built-in context menus. In addition, you can add your own custom context menu for a predefined set of xamGantt areas or, if you want, to override an existing context menu.
XamGantt uses an instance of the GanttContextMenuProvider class to define the default context menus. Context menus are identified by the GanttContextMenuArea enumeration.
You can use the GanttContextMenuProvider
’s ResourceOverrides property to add a custom ResourceDictionary. In this ResourceDictionary you can specify your additional context menus.
GanttContextMenuArea
enumeration is used to identify the context menus. XamGantt comes with default menus for members of this enumeration and you have the ability to add context menus for other members of the enumeration or to override the existing context menus.
This code example shows you how to create additional context menus for TimescaleArea and TimescaleBandHeader for xamGantt . It adds a resource dictionary to the GanttContexMenuProvider.ResourceOverrides. In the resource dictionary there are defined two xamContextMenu, one for the TimescaleArea and one for the TimescaleBandHeader area.
To complete the code example, you should have a xamGantt project. You can follow the instructions in Adding xamGantt to a Page in order to create sample xamGantt project.
You must also change the mark-up for the xamGantt
to coincide with example shown in code section of this topic.
This is a preview of a completed sample project. You can see the additional context menu for the timescale band header area.
In XAML:
<ig:XamGantt x:Name="xamGantt" Project="{Binding Project}">
<ig:XamGantt.ContextMenuProvider>
<ig:GanttContextMenuProvider>
<ig:GanttContextMenuProvider.ResourceOverrides>
<ResourceDictionary>
<ig:XamContextMenu x:Key="TimescaleArea">
<ig:XamMenuItem Header="Show timescale..." />
<ig:XamMenuItem Header="Show split..." />
</ig:XamContextMenu>
<ig:XamContextMenu x:Key="TimescaleBandHeader">
<ig:XamMenuItem Header="Timescale ..." />
<ig:XamMenuItem Header="Zoom..." />
<ig:XamMenuItem Header="Change working time..." />
<ig:XamMenuItem Header="More..." />
</ig:XamContextMenu>
</ResourceDictionary>
</ig:GanttContextMenuProvider.ResourceOverrides>
</ig:GanttContextMenuProvider>
</ig:XamGantt.ContextMenuProvider>
</ig:XamGantt>
The following topics provide additional information related to this topic: