wpf-devexpress-dot-xpf-dot-scheduling-dot-schedulercontrol-6a948704.md
Occurs every time the pop-up menu menu is invoked.
Namespace : DevExpress.Xpf.Scheduling
Assembly : DevExpress.Xpf.Scheduling.v25.2.dll
NuGet Package : DevExpress.Wpf.Scheduling
public event PopupMenuShowingEventHandler PopupMenuShowing
Public Event PopupMenuShowing As PopupMenuShowingEventHandler
The PopupMenuShowing event's data class is PopupMenuShowingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets whether the event should be canceled. Inherited from CancelRoutedEventArgs. |
| Handled | Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs. |
| Menu | Provides access to the invoked context menu. |
| MenuType | Indicates the type of the current context menu. |
| OriginalSource | Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs. |
| RoutedEvent | Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs. |
| Source | Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| InvokeEventHandler(Delegate, Object) | When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs. |
| OnSetSource(Object) | When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs. |
Handle the PopupMenuShowing event to dynamically customize the Scheduler popup menus. Use the Menu property to obtain the current pop-up menu. The MenuType property provides information about the current menu type (appointment, time cell, time ruler or appointment drop).
Tip
Use the OptionsContextMenu class properties to provide the built-in context menu with necessary customization actions or substitute it with a custom menu in XAML. Refer to the Pop-Up Menus topic for details.
private void scheduler_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
//Customize the cell context menu:
if (e.MenuType == ContextMenuType.CellContextMenu)
{
PopupMenu menu = (PopupMenu)e.Menu;
//Change the "New All Day Event" item's caption to "Create All-Day Appointment":
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;
}
}
}
//Add new menu item:
if (!menu.Items.Contains(myMenuItem))
{
CreateNewItem();
menu.Items.Add(myMenuItem);
}
}
}
private void CreateNewItem()
{
//Create a new menu item:
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)
{
// Implement a custom action.
MessageBox.Show(String.Format("{0} is clicked", e.Item.Name));
}
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
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PopupMenuShowing event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
WorkTime="06:00:00-23:00:00"
PopupMenuShowing="scheduler_PopupMenuShowing">
<dxsch:DayView x:Name="dayView1"
#line 16 "..\..\..\MainWindow.xaml"
this.scheduler.PopupMenuShowing += new DevExpress.Xpf.Scheduling.PopupMenuShowingEventHandler(this.scheduler_PopupMenuShowing);
#ExternalSource("..\..\MainWindow.xaml",16)
AddHandler Me.scheduler.PopupMenuShowing, New DevExpress.Xpf.Scheduling.PopupMenuShowingEventHandler(AddressOf Me.scheduler_PopupMenuShowing)
See Also