Back to Devexpress

Node Selection in Tree View for .NET MAUI

maui-404968-tree-view-node-selection.md

latest2.0 KB
Original Source

Node Selection in Tree View for .NET MAUI

  • Jul 03, 2024

DXTreeView supports single node selection.

To select and deselect nodes, enable AllowSelection and AllowDeselectSingleItem properties.

A user can tap a node to select it. The SelectedItem property then returns the corresponding data source item. A user can tap the selected node again to clear selection. The SelectedItem property then returns null.

xaml
<dx:DXTreeView ...
    ItemsSource="{Binding Nodes}"
    AllowSelection="True"
    AllowDeselectSingleItem="True"
    SelectedItem="{Binding SelectedNodes}">
    ...
</dx:DXTreeView>

Respond to Selection Changes

The DXTreeView ships with the following selection-related events. These events may be triggered from the UI (a user taps a node) or from code (the SelectedItem property value changes):

SelectedItemChangedFires when the selected item is changed.SelectedItemChangingFires when a user attempts to select an item, but before selection changes.

Change Selected Node Appearance

Use SelectedBackgroundColor and SelectedBorderColor properties to change selected node appearance. For more information, refer to the following help topic: Change Selected Node Appearance.