RayCraftDocs
v1.0.3 raycraft.dev
On this page

TreeView

Free

Hierarchical 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

TreeView control

Parameters

ParameterTypeDescription
CanDropFunc<TItem, Object, bool>Tells whether the dragged payload may be dropped on a node (TreeView, default yes).
CheckableboolShows a check box on every node; parents show a mixed state.
CheckedItemsIEnumerable<TItem>Checked nodes. Use with @bind-CheckedItems.
ChildrenLoaderFunc<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.
ChildrenSelectorFunc<TItem, IEnumerable<TItem>>Returns the children of an item. Items without children are leaves.
ClassstringExtra CSS classes added to the root element.
ContextMenuItemsFunc<TItem, IReadOnlyList<MenuCommand>>Returns the context menu commands of a node; opens on right click, the Menu key and Shift+F10 (TreeView).
ExpandAllboolExpands every node when the tree first appears.
HasChildrenFunc<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.
ItemBadgeFunc<TItem, string>Short text shown at the end of a node, for example an unread count; empty shows nothing (TreeView).
ItemBoldFunc<TItem, bool>Tells whether the name of a node is bold, for example when it has unread items (TreeView).
ItemsIEnumerable<TItem>The options to choose from.
ItemTemplateRenderFragment<TItem>Custom content for each node. The item is available as context.
ItemTextFunc<TItem, string>Converts an item to its display text (defaults to ToString()).
LabelstringVisible label text (charts: accessible name; IconButton: accessible name and tooltip).
SelectedItemTItemSelected node. Use with @bind-SelectedItem.
StylestringInline style added to the root element.

Events

EventTypeDescription
CheckedItemsChangedEventCallback<IEnumerable<TItem>>Raised when the checked nodes change.
OnDropEventCallback<TreeDropEventArgs<TItem>>Raised when a payload started with IRayCraftDrag.Begin is dropped on a node (TreeView).
OnLoadErrorEventCallback<Exception>Raised with the exception when ChildrenLoader fails; the node collapses.
SelectedItemChangedEventCallback<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.