Back to Devexpress

TreeViewControl.CanUnselectNode Event

wpf-devexpress-dot-xpf-dot-grid-dot-treeviewcontrol-ead2e7f6.md

latest2.1 KB
Original Source

TreeViewControl.CanUnselectNode Event

Occurs when a user tries to unselect a node and allows you to control whether a user can unselect a particular node.

Namespace : DevExpress.Xpf.Grid

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

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event CanUnselectNodeEventHandler CanUnselectNode
vb
Public Event CanUnselectNode As CanUnselectNodeEventHandler

Event Data

The CanUnselectNode event's data class is DevExpress.Xpf.Grid.TreeList.CanUnselectNodeEventArgs.

Remarks

Set the TreeViewControl.SelectionMode property to the Cell/Row/MultipleRow value to use the CanUnselectNode event.

The following code sample does not allow users to unselect root nodes.

xaml
<dxg:TreeViewControl x:Name="treeview"
                     CanUnselectNode="treeview_CanUnselectNode"
                     SelectionMode="Row"/>
csharp
void treeview_CanUnselectNode(object sender, DevExpress.Xpf.Grid.TreeList.CanUnselectNodeEventArgs e) {
    e.CanUnselectNode = e.Node.Level != 0;
}
vb
Private Sub treeview_CanUnselectNode(ByVal sender As Object, ByVal e As DevExpress.Xpf.Grid.TreeList.CanUnselectNodeEventArgs)
    e.CanUnselectNode = e.Node.Level <> 0
End Sub

Handle the CanSelectNode event to control whether a user can select a particular node.

See Also

TreeViewControl Class

TreeViewControl Members

DevExpress.Xpf.Grid Namespace