Tree View
An expandable tree of rows, with selection.
Installation
bash
shellui-native add tree-view
Platforms: MAUI · Avalonia. Also installs icon, element-extensions.
Usage
Basic
<ui:TreeView SelectedValueChanged="OnFileSelected">
<ui:TreeViewItem Text="src" Icon="Folder" IsExpanded="True">
<ui:TreeViewItem Text="Components" Icon="Folder" IsExpanded="True">
<ui:TreeViewItem Text="Button.cs" Icon="File" />
<ui:TreeViewItem Text="Card.cs" Icon="File" />
</ui:TreeViewItem>
<ui:TreeViewItem Text="MainPage.xaml" Icon="FileText" />
</ui:TreeViewItem>
<ui:TreeViewItem Text="README.md" Icon="FileText" />
</ui:TreeView><ui:TreeView SelectedValueChanged="OnFileSelected">
<ui:TreeViewItem Text="src" Icon="Folder" IsExpanded="True">
<ui:TreeViewItem Text="Components" Icon="Folder" IsExpanded="True">
<ui:TreeViewItem Text="Button.cs" Icon="File" />
<ui:TreeViewItem Text="Card.cs" Icon="File" />
</ui:TreeViewItem>
<ui:TreeViewItem Text="MainWindow.axaml" Icon="FileText" />
</ui:TreeViewItem>
<ui:TreeViewItem Text="README.md" Icon="FileText" />
</ui:TreeView>Not available on yet
MAUI and Avalonia
Rows are tab stops on both platforms. On Avalonia, Right also expands a row and Left collapses it.
API
TreeView
XAML children go to Items.
| Property | Type | Default | Description |
|---|---|---|---|
SelectedValue |
string |
— | The selected item's Value (its Text when no Value is set). |
| Event | Arguments | Description |
|---|---|---|
SelectedValueChanged |
string? |
User input only: setting SelectedValue from code or a binding doesn't raise it. |
TreeViewItem
XAML children go to Items.
| Property | Type | Default | Description |
|---|---|---|---|
Text |
string |
— | Text shown by the component. |
Value |
string |
— | Identifies the item; reported as the tree's SelectedValue. |
Icon |
IconName |
None |
Lucide icon from IconName; None for no icon. |
IsExpanded |
bool |
false |
Whether the item's children are shown. |