Back to Devexpress

PropertyGridControl.MenuOpening Event

wpf-devexpress-dot-xpf-dot-propertygrid-dot-propertygridcontrol-3b7e59a8.md

latest8.9 KB
Original Source

PropertyGridControl.MenuOpening Event

Occurs when a user opens a property grid menu and allows you to customize this menu.

Namespace : DevExpress.Xpf.PropertyGrid

Assembly : DevExpress.Xpf.PropertyGrid.v25.2.dll

NuGet Package : DevExpress.Wpf.PropertyGrid

Declaration

csharp
public event EventHandler<PropertyGridMenuEventArgs> MenuOpening
vb
Public Event MenuOpening As EventHandler(Of PropertyGridMenuEventArgs)

Event Data

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

PropertyDescription
CustomizationsGets a collection of menu customizations applied in this event handler.
HandledGets 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.
ItemsGets items displayed in the invoked menu.
MenuGets the invoked menu.
MenuTypeGets the invoked menu’s type.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
RowGets a property grid row. Inherited from PropertyGridRowBaseEventArgs.
SourceGets the PropertyGridControl that raised the event.
TargetElementGets the UI element for which the menu is shown.
ValueGets a row’s value. Inherited from PropertyGridRowBaseEventArgs.

The event data class exposes the following methods:

MethodDescription
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.

Remarks

The following example adds tooltips to items displayed in the Issues collection’s new item menu:

View Example: Show Tooltips in the New Item Menu

xaml
<dxprg:PropertyGridControl x:Name="propertyGrid" ShowCategories="Hidden" MenuOpening="OnMenuOpening"/>
cs
using DevExpress.Xpf.Core;
using DevExpress.Xpf.PropertyGrid;
// ...
private void OnMenuOpening(object sender, PropertyGridMenuEventArgs e) {
    if (e.MenuType == PropertyGridMenuType.NewItem && e.Row.Path == "Issues") {
        e.Items[0].ToolTip = "Create a new breaking change.";
        e.Items[1].ToolTip = "Report a new bug.";
        e.Items[2].ToolTip = "Ask a new question.";
    }
}
vb
Imports DevExpress.Xpf.Core
Imports DevExpress.Xpf.PropertyGrid
' ...
Private Sub OnMenuOpening(ByVal sender As Object, ByVal e As PropertyGridMenuEventArgs)
    If e.MenuType = PropertyGridMenuType.NewItem AndAlso Equals(e.Row.Path, "Issues") Then
        e.Items(0).ToolTip = "Create a new breaking change."
        e.Items(1).ToolTip = "Report a new bug."
        e.Items(2).ToolTip = "Ask a new question."
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the MenuOpening 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.

wpf-property-grid-show-tooltips-in-new-item-menu/CS/PropertyGridMenuOpening/MainWindow.xaml#L8

xml
Title="MainWindow" Height="800" Width="1000">
    <dxprg:PropertyGridControl x:Name="propertyGrid" ShowCategories="Hidden" MenuOpening="OnMenuOpening"/>
</dx:ThemedWindow>

wpf-property-grid-show-tooltips-in-new-item-menu/CS/PropertyGridMenuOpening/obj/Debug/net472/MainWindow.g.cs#L93

csharp
#line 8 "..\..\..\MainWindow.xaml"
this.propertyGrid.MenuOpening += new System.EventHandler<DevExpress.Xpf.PropertyGrid.PropertyGridMenuEventArgs>(this.OnMenuOpening);

wpf-property-grid-show-tooltips-in-new-item-menu/VB/PropertyGridMenuOpening/obj/Debug/net8.0-windows/MainWindow.g.vb#L94

vb
#ExternalSource("..\..\..\MainWindow.xaml",8)
AddHandler Me.propertyGrid.MenuOpening, New System.EventHandler(Of DevExpress.Xpf.PropertyGrid.PropertyGridMenuEventArgs)(AddressOf Me.OnMenuOpening)

See Also

Property Menu

ShowPropertyMenu(String)

ShowNewItemMenu(String)

HideMenu()

PropertyGridControl Class

PropertyGridControl Members

DevExpress.Xpf.PropertyGrid Namespace