TreeViewControl.ShowNodeMenu Event
In This Article
Occurs before a user opens a node’s context menu and allows you to customize this menu.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.dll
NuGet Package: DevExpress.Wpf.Grid.Core
#Declaration
#Event Data
The ShowNodeMenu event's data class is TreeViewNodeMenuEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Customizations | Gets a collection of actions for the context menu. |
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 Routed |
Items | Gets a collection of context menu items. |
Node | Gets a node for which the context menu is shown. |
Original |
Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.
Inherited from Routed |
Routed |
Gets or sets the Routed |
Source |
Gets or sets a reference to the object that raised the event.
Inherited from Routed |
Target |
Gets a UI element for which the context menu is shown. |
The event data class exposes the following methods:
Method | Description |
---|---|
Invoke |
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 Routed |
On |
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 Routed |
#Remarks
Use the NodeMenuCustomizations property to add items to a node’s context menu.
The following code sample removes the Delete Node item from the context menu for root nodes:
<Window
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
... >
<dxg:TreeViewControl ...
ShowNodeMenu="treeview_ShowNodeMenu">
<dxg:TreeViewControl.NodeMenuCustomizations>
<dxb:BarButtonItem Name="deleteNode" Content="Delete Node"/>
<dxb:BarButtonItem Name="copyNodeData" Content="Copy Node Data"/>
</dxg:TreeViewControl.NodeMenuCustomizations>
</dxg:TreeViewControl>
void treeview_ShowNodeMenu(object sender, DevExpress.Xpf.Grid.TreeList.TreeViewNodeMenuEventArgs e) {
if (e.Node.Level == 0) e.Customizations.Add(new RemoveAction { ElementName = "deleteNode"} );
}
See Also