TreeView
FreeHierarchical list following the ARIA tree pattern. Arrow keys move and expand, Home and End jump, Enter or Space selects. Children come from ChildrenSelector, so any recursive type works, or from an asynchronous ChildrenLoader that runs when a node is first opened.
Example

Parameters
| Parameter | Type | Description |
|---|---|---|
CanDrop | Func<TItem, Object, bool> | Tells whether the dragged payload may be dropped on a node (TreeView, default yes). |
Checkable | bool | Shows a check box on every node; parents show a mixed state. |
CheckedItems | IEnumerable<TItem> | Checked nodes. Use with @bind-CheckedItems. |
ChildrenLoader | Func<TItem, Task<IEnumerable<TItem>>> | Loads the children of a node when it is first opened (returns a task). While it runs the node shows a spinner and aria-busy; a failure collapses the node and raises OnLoadError. |
ChildrenSelector | Func<TItem, IEnumerable<TItem>> | Returns the children of an item. Items without children are leaves. |
Class | string | Extra CSS classes added to the root element. |
ContextMenuItems | Func<TItem, IReadOnlyList<MenuCommand>> | Returns the context menu commands of a node; opens on right click, the Menu key and Shift+F10 (TreeView). |
ExpandAll | bool | Expands every node when the tree first appears. |
HasChildren | Func<TItem, bool> | Tells before loading whether a node has children (so it shows the expand arrow). Without it every node can be opened when ChildrenLoader is set. |
ItemBadge | Func<TItem, string> | Short text shown at the end of a node, for example an unread count; empty shows nothing (TreeView). |
ItemBold | Func<TItem, bool> | Tells whether the name of a node is bold, for example when it has unread items (TreeView). |
Items | IEnumerable<TItem> | The options to choose from. |
ItemTemplate | RenderFragment<TItem> | Custom content for each node. The item is available as context. |
ItemText | Func<TItem, string> | Converts an item to its display text (defaults to ToString()). |
Label | string | Visible label text (charts: accessible name; IconButton: accessible name and tooltip). |
SelectedItem | TItem | Selected node. Use with @bind-SelectedItem. |
Style | string | Inline style added to the root element. |
Events
| Event | Type | Description |
|---|---|---|
CheckedItemsChanged | EventCallback<IEnumerable<TItem>> | Raised when the checked nodes change. |
OnDrop | EventCallback<TreeDropEventArgs<TItem>> | Raised when a payload started with IRayCraftDrag.Begin is dropped on a node (TreeView). |
OnLoadError | EventCallback<Exception> | Raised with the exception when ChildrenLoader fails; the node collapses. |
SelectedItemChanged | EventCallback<TItem> | Raised when another node is selected. |
Package
TreeView is part of RayCraft Free. Package: RayCraft.Blazor. It comes from nuget.org. See Getting started.
Send feedbackVersion 1.0.3