SchedulerControl.PopupMenuShowing Event

Occurs before a popup menu is created for the SchedulerControl every time a popup menu is invoked.

Namespace: DevExpress.Xpf.Scheduler

Assembly: DevExpress.Xpf.Scheduler.v20.1.dll

Declaration

public event SchedulerMenuEventHandler PopupMenuShowing
Public Event PopupMenuShowing As SchedulerMenuEventHandler

Event Data

The PopupMenuShowing event's data class is SchedulerMenuEventArgs. The following properties provide information specific to this event:

Property Description
Customizations Provides access to a collection of customizations of the popup menu, customized via the SchedulerControl.PopupMenuShowing event handler.
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 Gets the popup menu for which the SchedulerControl.PopupMenuShowing event has been raised.
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.

Remarks

IMPORTANT

You are viewing documentation for the legacy WPF Scheduler control. If you're starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

Handle the PopupMenuShowing event to dynamically customize the Scheduler control popup menus at runtime. For example, you can remove existing menu items and/or add new items. Use the SchedulerMenuEventArgs.Menu property to get access to the current popup menu and modify the list of menu items via the SchedulerMenuEventArgs.Customizations collection.

You can also customize the scheduler's default, appointment and time ruler popup menus via the SchedulerControl.DefaultMenuCustomizations, SchedulerControl.AppointmentMenuCustomizations and SchedulerControl.TimeRulerMenuCustomizations properties.

NOTE

Use e.Menu.Items collection to iterate on menu items for v14.2 and higher. Previous versions use iteration on e.Menu.ItemLinks.

Examples

This example demonstrates how to customize the SchedulerControl's context menu at runtime by removing the New Recurring Appointment menu item from the Default Popup Menu, and adding a custom item instead.

Handle the SchedulerControl.PopupMenuShowing event. In the event handler, use the SchedulerMenuEventArgs.Menu property to determine whether the default popup menu raised an event, and modify the SchedulerMenuEventArgs.Customizations collection to add or remove popup menu items.

Private Sub schedulerControl1_PopupMenuShowing(ByVal sender As Object, ByVal e As SchedulerMenuEventArgs)
    ' Check whether this event was raised for a default popup menu of the Scheduler control.
    If e.Menu.Name = SchedulerMenuItemName.DefaultMenu Then
        For i As Integer = 0 To e.Menu.Items.Count - 1
            Dim menuItem As SchedulerBarItem = TryCast(e.Menu.Items(i), SchedulerBarItem)
            If menuItem IsNot Nothing Then
                If menuItem IsNot Nothing AndAlso menuItem.Name = SchedulerMenuItemName.NewAllDayEvent Then
                    menuItem.Content = "Create All-Day Appointment"
                    Exit For
                End If
            End If
        Next i

        ' Remove the New Recurring Event menu item using the Action approach.
        e.Customizations.Add(New RemoveBarItemAndLinkAction() With {.ItemName = SchedulerMenuItemName.NewRecurringEvent})

        ' Create a custom menu item.
        Dim myMenuItem As New BarButtonItem()
        myMenuItem.Name = "customItem"
        myMenuItem.Content = "Item Added at Runtime"
        AddHandler myMenuItem.ItemClick, AddressOf customItem_ItemClick

        ' Insert a menu separator.
        e.Customizations.Add(New BarItemLinkSeparator())
        ' Insert a new item into the Scheduler popup menu.
        e.Customizations.Add(myMenuItem)
    End If
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
See Also