Cell Pop-Up Menu
Appears when right-clicking an empty time cell.

Appointment Pop-Up Menu
Appears when right-clicking an appointment.

Appointment Drag Pop-Up Menu
Appears when dragging an appointment with the right mouse button.

Time Ruler Pop-Up Menu
Appears when right-clicking a time ruler.

Resource Tree Pop-Up Menu
Appears when right-clicking any item or empty space in Resource Tree.

Handle the SchedulerControl.PopupMenuShowing event to customize popup menus at runtime. Use the Menu (see PopupMenuShowingEventArgs.Menu) property to obtain the current pop-up menu. The MenuType (see PopupMenuShowingEventArgs.MenuType) property provides information about the current menu type (appointment, time cell, time ruler or appointment drop). See the example below.
MainWindow.xaml.cs |
private void scheduler_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
if (e.MenuType == ContextMenuType.CellContextMenu)
{
PopupMenu menu = (PopupMenu)e.Menu;
for (int i = 0; i < menu.Items.Count; i++)
{
BarItem menuItem = menu.Items[i] as BarItem;
if (menuItem != null)
{
if (menuItem != null && menuItem.Content.ToString() == "New All Day Event")
{
menuItem.Content = "Create All-Day Appointment";
break;
}
}
}
if (!menu.Items.Contains(myMenuItem))
{
CreateNewItem();
menu.Items.Add(myMenuItem);
}
}
}
private void CreateNewItem()
{
myMenuItem = new BarButtonItem();
myMenuItem.Name = "customItem";
myMenuItem.Content = "Item Added at Runtime";
myMenuItem.ItemClick += new ItemClickEventHandler(customItem_ItemClick);
}
private void customItem_ItemClick(object sender, ItemClickEventArgs e)
{
MessageBox.Show(String.Format("{0} is clicked", e.Item.Name));
}
|
MainWindow.xaml.vb |
Private Sub scheduler_PopupMenuShowing(ByVal sender As Object, ByVal e As PopupMenuShowingEventArgs)
'Customize the cell context menu:
If e.MenuType = ContextMenuType.CellContextMenu Then
Dim menu As PopupMenu = CType(e.Menu, PopupMenu)
'Change the "New All Day Event" item's caption to "Create All-Day Appointment":
For i As Integer = 0 To menu.Items.Count - 1
Dim menuItem As BarItem = TryCast(menu.Items(i), BarItem)
If menuItem IsNot Nothing Then
If menuItem IsNot Nothing AndAlso menuItem.Content.ToString() = "New All Day Event" Then
menuItem.Content = "Create All-Day Appointment"
Exit For
End If
End If
Next i
'Add new menu item:
If Not menu.Items.Contains(myMenuItem) Then
CreateNewItem()
menu.Items.Add(myMenuItem)
End If
End If
End Sub
Private Sub CreateNewItem()
'Create a new menu item:
myMenuItem = New BarButtonItem()
myMenuItem.Name = "customItem"
myMenuItem.Content = "Item Added at Runtime"
AddHandler myMenuItem.ItemClick, AddressOf customItem_ItemClick
End Sub
Private Sub customItem_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
' Implement a custom action.
MessageBox.Show(String.Format("{0} is clicked", e.Item.Name))
End Sub
|
Tip
Use the scheduler's Smart Tag to generate a default context menu for appointments, time rulers or time cells in design-time, and customize it as required. Refer to the Create Context Menu topic for details.
-
Add a New Item
The OptionsContextMenu class provides options that allow you to customize context menus. Use the *ContextMenuActions property to access the target context menu's actions collection. Add an InsertAction to the retrieved collection to add a new item to the context menu. The following code sample inserts two new items to the appointment context menu.
MainWindow.xaml |
<dxsch:OptionsContextMenu.AppointmentContextMenuActions>
<!--Insert the "Recurrence" item invoking the Recurrence dialog-->
<dxb:InsertAction Index="-1">
<dxb:BarButtonItem Content="Recurrence"
Glyph="{dx:DXImage Image=Recurrence_32x32.png}"
Command="{Binding ElementName=schedulerCommands, Path=OpenRecurrenceWindowCommand}">
</dxb:BarButtonItem>
</dxb:InsertAction>
<!--Insert the check item which converts the selected appointment to an all day event-->
<dxb:InsertAction>
<dxb:BarCheckItem x:Name="allDayCheck"
Content="All-Day Appointment"
Glyph="{dx:DXImage Image=Check_16x16.png}"
CheckedChanged="allDayCheck_CheckedChanged"/>
</dxb:InsertAction>
</dxsch:OptionsContextMenu.AppointmentContextMenuActions>
|
As a result, the menu appears as follows.

-
Update an Existing Item
Obtain the context menu's action collection and add an UpdateAction to it to update any existing context menu item, as shown in the code sample below.
MainWindow.xaml |
<dxsch:OptionsContextMenu.TimeRulerContextMenuActions>
<!--Hide the "New All Day Event" and "New Recurring Event" items-->
<dxb:UpdateAction ElementName="{x:Static Member=dxsch:DefaultBarItemNames.ContextMenu_Items_TimeRuler_Actions_NewAllDayEvent}"
PropertyName="IsVisible"
Value="False"/>
<dxb:UpdateAction ElementName="{x:Static Member=dxsch:DefaultBarItemNames.ContextMenu_Items_TimeRuler_Actions_NewRecurringEvent}"
PropertyName="IsVisible"
Value="False"/>
<!--Disable the "New Appointment" and "New Recurring Appointment" item-->
<dxb:UpdateAction ElementName="{x:Static Member=dxsch:DefaultBarItemNames.ContextMenu_Items_TimeRuler_Actions_NewAppointment}"
PropertyName="IsEnabled"
Value="False"/>
<dxb:UpdateAction ElementName="{x:Static Member=dxsch:DefaultBarItemNames.ContextMenu_Items_TimeRuler_Actions_NewRecurringAppointment}"
PropertyName="IsEnabled"
Value="False"/>
</dxsch:OptionsContextMenu.TimeRulerContextMenuActions>
|
The image shows the code execution result.

-
Remove the Item
Add a RemoveAction to the menu's action collection to delete any item from the target context menu. The code snippet shows how to delete an item from the appointment drop context menu.
MainWindow.xaml |
<dxsch:OptionsContextMenu.AppointmentDropContextMenuActions>
<!--Remove the "Copy" item-->
<dxb:RemoveAction ElementName="{x:Static Member=dxsch:DefaultBarItemNames.ContextMenu_Items_AppointmentDrop_Actions_CopyAppointmentsOnDrop}"/>
</dxsch:OptionsContextMenu.AppointmentDropContextMenuActions>
|
The resulting context menu is shown on the image below.

The OptionsContextMenu.*ContextMenu properties allow you to provide a custom context menu instead of the default one. The code sample below shows how to provide a custom cell pop-up menu shown in the image.

MainWindow.xaml |
<dxsch:OptionsContextMenu.CellContextMenu>
<dxb:PopupMenu>
<dxb:PopupMenu.Items>
<dxb:BarButtonItem Content="Add Broadcast..."
Glyph="{dx:DXImage Image=Appointment_16x16.png}"
Command="{Binding ElementName=schedulerCommands, Path=ShowNewAppointmentWindowCommand}"/>
<dxb:BarButtonItem Content="Add News Block..."
Glyph="{dx:DXImage Image=RecurringAppointment_16x16.png}"
Command="{Binding ElementName=schedulerCommands, Path=ShowNewRecurringAppointmentWindowCommand}"/>
</dxb:PopupMenu.Items>
</dxb:PopupMenu>
</dxsch:OptionsContextMenu.CellContextMenu>
|