Skip to main content

SchedulerMenuEventArgs Class

Provides data for the SchedulerControl.PopupMenuShowing event.

Namespace: DevExpress.Xpf.Scheduler

Assembly: DevExpress.Xpf.Scheduler.v24.2.dll

NuGet Package: DevExpress.Wpf.Scheduler

Declaration

public class SchedulerMenuEventArgs :
    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.

The SchedulerControl.PopupMenuShowing event occurs before a popup menu is created for a Scheduler control, every time this menu is invoked. The SchedulerMenuEventArgs class introduces the SchedulerMenuEventArgs.Menu property that provides access to the popup menu for which the event was raised, and the SchedulerMenuEventArgs.Customizations property, allowing you to customize the popup menu.

Note, that SchedulerMenuEventArgs objects are automatically created, initialized and passed to SchedulerControl.PopupMenuShowing event handlers.

Example

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.

<dxsch:SchedulerControl Name="schedulerControl1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                        PopupMenuShowing="schedulerControl1_PopupMenuShowing">
private void schedulerControl1_PopupMenuShowing(object sender, SchedulerMenuEventArgs e) {
    // Check whether this event was raised for a default popup menu of the Scheduler control.
    if (e.Menu.Name == SchedulerMenuItemName.DefaultMenu)
    {
        for (int i = 0; i < e.Menu.Items.Count; i++)
        {
            SchedulerBarItem menuItem = e.Menu.Items[i] as SchedulerBarItem;
            if (menuItem != null)
            {
                if (menuItem != null && menuItem.Name == SchedulerMenuItemName.NewAllDayEvent)
                {
                    menuItem.Content = "Create All-Day Appointment";
                    break;
                }
            }
        }

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

        // Create a custom menu item.
        BarButtonItem myMenuItem = new BarButtonItem();
        myMenuItem.Name = "customItem";
        myMenuItem.Content = "Item Added at Runtime";
        myMenuItem.ItemClick += new ItemClickEventHandler(customItem_ItemClick);

        // Insert a menu separator.
        e.Customizations.Add(new BarItemLinkSeparator());
        // Insert a new item into the Scheduler popup menu.
        e.Customizations.Add(myMenuItem);
    } 
}

private void customItem_ItemClick(object sender, ItemClickEventArgs e) {
    // Implement a custom action.
    MessageBox.Show(String.Format("{0} is clicked", e.Item.Name));
}

Inheritance

Object
EventArgs
RoutedEventArgs
SchedulerMenuEventArgs
See Also