wpf-devexpress-dot-xpf-dot-propertygrid-dot-propertygridcontrol-3b7e59a8.md
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
public event EventHandler<PropertyGridMenuEventArgs> MenuOpening
Public Event MenuOpening As EventHandler(Of PropertyGridMenuEventArgs)
The MenuOpening event's data class is PropertyGridMenuEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Customizations | Gets a collection of menu customizations applied in this 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. |
| Items | Gets items displayed in the invoked menu. |
| Menu | Gets the invoked menu. |
| MenuType | Gets the invoked menu’s type. |
| 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. |
| Row | Gets a property grid row. Inherited from PropertyGridRowBaseEventArgs. |
| Source | Gets the PropertyGridControl that raised the event. |
| TargetElement | Gets the UI element for which the menu is shown. |
| Value | Gets a row’s value. Inherited from PropertyGridRowBaseEventArgs. |
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. |
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
<dxprg:PropertyGridControl x:Name="propertyGrid" ShowCategories="Hidden" MenuOpening="OnMenuOpening"/>
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.";
}
}
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
Title="MainWindow" Height="800" Width="1000">
<dxprg:PropertyGridControl x:Name="propertyGrid" ShowCategories="Hidden" MenuOpening="OnMenuOpening"/>
</dx:ThemedWindow>
#line 8 "..\..\..\MainWindow.xaml"
this.propertyGrid.MenuOpening += new System.EventHandler<DevExpress.Xpf.PropertyGrid.PropertyGridMenuEventArgs>(this.OnMenuOpening);
#ExternalSource("..\..\..\MainWindow.xaml",8)
AddHandler Me.propertyGrid.MenuOpening, New System.EventHandler(Of DevExpress.Xpf.PropertyGrid.PropertyGridMenuEventArgs)(AddressOf Me.OnMenuOpening)
See Also