Skip to main content

GridControl.ContextMenuOpening Event

Occurs before the context menu is opened.

Namespace: DevExpress.UI.Xaml.Grid

Assembly: DevExpress.UI.Xaml.Grid.v21.2.dll

NuGet Package: DevExpress.Uwp.Controls

Declaration

public event EventHandler<ContextMenuOpeningEventArgs> ContextMenuOpening

Event Data

The ContextMenuOpening event's data class is DevExpress.UI.Xaml.ContextMenuOpeningEventArgs.

Remarks

Use this event if you want to add custom items to the default context menu. The event’s Info property returns an object that stores the menu settings. The below snippets illustrate how you can add custom menu items to the default context menu shown for GridControl columns:

private void GridControl_ContextMenuOpening(object sender, DevExpress.UI.Xaml.ContextMenuOpeningEventArgs e)
{
    var menuInfo = e.Info as GridColumnContextMenuInfo;
    if(menuInfo != null)
    {
        var toolbar = menuInfo.MenuContent as ContextToolbarControl;
        toolbar.Group.Items.Add(new ContextToolbarButton() { Content = "Clear Filtering", Command = menuInfo.Commands.ClearFilter });
        toolbar.Group.Items.Add(new ContextToolbarButton() { Content = "Clear Grouping", Command = menuInfo.Commands.ClearGrouping });
    }
}
See Also