DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsTreeview

DwsTreeview renders hierarchical data bound from a plain .NET collection - nested (via ChildrenSelector) or flat/self-referencing (via ParentKeySelector) - with selection, lazy loading, drag-and-drop, search, inline rename, context menus and keyboard/ARIA support. Its parts are the library's own components: the expand toggles are DwsButtons, the checkboxes DwsCheckBoxes, the rename field a DwsInput and the context menu a DwsContextMenu (right-click, long press on a touch screen, the context menu key or Shift+F10). On touch screens the toggles and checkboxes are 44px, and with haptics switched on (settings dialog) a tap that selects a node plays the Haptic feedback.

API Reference

Nested data binding

Bind to a collection whose items already contain their own children via ChildrenSelector.

Nested tree
  • src
    • Components
      • Button.razor
      • Card.razor
    • Services
      • ApiClient.cs
  • docs
    • README.md
    • CHANGELOG.md
  • tests
    • Unit
      • ButtonTests.cs
  • package.json
Show Code
Treeview.razor
<DwsTreeview Name="MyTree" Caption="Nested tree" T="DemoFileNode"
             Items="@_treeBasic"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             DefaultExpandedDepth="0" />

@code {
    private readonly List<DemoFileNode> _treeBasic = BuildFileTree();
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Flat, self-referencing data binding

Bind to a flat list where each item points at its parent's key via ParentKeySelector. Items with no matching parent become roots.

Flat tree
  • Engineering - A. Rossi
    • Platform - B. Chen
      • Infrastructure - D. Novak
    • Product Engineering - C. Diaz
      • Web - E. Kim
      • Mobile - F. Adeyemi
  • Design - G. Silva
Show Code
Treeview.razor
<DwsTreeview Name="MyOrgTree" Caption="Flat tree" T="DemoOrgUnit"
             Items="@_orgUnits"
             ItemKeySelector="@(item => item.Id)"
             ParentKeySelector="@(item => item.ParentId)"
             LabelSelector="@(item => $"{item.Title} - {item.Lead}")"
             DefaultExpandedDepth="1" />

@code {
    public sealed class DemoOrgUnit
    {
        public int Id { get; init; }
        public int? ParentId { get; init; }
        public string Title { get; init; } = string.Empty;
        public string Lead { get; init; } = string.Empty;
    }

    // Items whose ParentId matches no Id (here null) become roots.
    private readonly List<DemoOrgUnit> _orgUnits =
    [
        new() { Id = 1, ParentId = null, Title = "Engineering", Lead = "A. Rossi" },
        new() { Id = 2, ParentId = 1, Title = "Platform", Lead = "B. Chen" },
        new() { Id = 3, ParentId = 1, Title = "Product Engineering", Lead = "C. Diaz" },
        new() { Id = 4, ParentId = 2, Title = "Infrastructure", Lead = "D. Novak" },
        new() { Id = 7, ParentId = null, Title = "Design", Lead = "G. Silva" },
    ];
}

Icons

IconSelector, ExpandedIconSelector and CollapsedIconSelector give per-node icons, independent of or reacting to the expand state.

Tree with icons
  • src
    • Components
      • Button.razor
      • Card.razor
    • Services
      • ApiClient.cs
  • docs
    • README.md
    • CHANGELOG.md
  • tests
    • Unit
      • ButtonTests.cs
  • package.json
Show Code
Treeview.razor
<DwsTreeview Name="MyIconTree" Caption="Tree with icons" T="DemoFileNode"
             Items="@_tree"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             IconSelector="GetFileIcon"
             ExpandedIconSelector="GetFolderExpandedIcon"
             CollapsedIconSelector="GetFolderCollapsedIcon"
             DefaultExpandedDepth="1" />

@code {
    private readonly List<DemoFileNode> _tree = BuildFileTree();

    private static string? GetFileIcon(DemoFileNode item) => item.Kind == "File" ? Icons.BS.FileEarmarkText : null;
    private static string? GetFolderExpandedIcon(DemoFileNode item) => item.Kind == "Folder" ? Icons.BS.Folder2Open : null;
    private static string? GetFolderCollapsedIcon(DemoFileNode item) => item.Kind == "Folder" ? Icons.BS.Folder2 : null;
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Node tooltips

NodeTooltipSelector adds a hover tooltip to a node's label; here every file shows its size.

Tree with tooltips
  • src
    • Components
      • Button.razor
      • Card.razor
    • Services
      • ApiClient.cs
  • docs
    • README.md
    • CHANGELOG.md
  • tests
    • Unit
      • ButtonTests.cs
  • package.json
Show Code
Treeview.razor
<DwsTreeview Name="MyTooltipTree" Caption="Tree with tooltips" T="DemoFileNode"
             Items="@_tree"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             NodeTooltipSelector="GetFileTooltip"
             DefaultExpandedDepth="1" />

@code {
    private readonly List<DemoFileNode> _tree = BuildFileTree();

    // null: no tooltip for that node.
    private static string? GetFileTooltip(DemoFileNode item) => item.Kind == "File" ? $"{item.SizeKb} KB" : null;
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Depth limit

MaxDepth caps how deep the hierarchy is materialised; deeper branches are dropped and a notice is shown.

Depth-limited tree
  • src
    • Components
    • Services
  • docs
    • README.md
    • CHANGELOG.md
  • tests
    • Unit
  • package.json

Some nodes are hidden because the maximum nesting depth of 1 was reached.

Show Code
Treeview.razor
<DwsInput T="int?" Name="MyDepthInput" Label="Max depth" ValueType="DwsStringType.INTEGER_NUMBER"
          MinValue="0" MaxValue="4" ShowErrorMessage="false" ReserveErrorSpace="false"
          Value="@_maxDepth" ValueChanged="@((int? value) => _maxDepth = value)" />

<DwsTreeview Name="MyDepthTree" Caption="Depth-limited tree" T="DemoFileNode"
             Items="@_tree"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             MaxDepth="@_maxDepth"
             DefaultExpandedDepth="3" />

@code {
    private readonly List<DemoFileNode> _tree = BuildFileTree();
    private int? _maxDepth = 1;
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Badges and child counts

BadgeSelector (with BadgeColorSelector) adds a badge next to a node's label, here a file's size; ChildCountBadge adds a folder's direct child count.

Tree with badges
  • src
    • Components
      • Button.razor4 KB
      • Card.razor6 KB
    • Services
      • ApiClient.cs12 KB
  • docs
    • README.md3 KB
    • CHANGELOG.md2 KB
  • tests
    • Unit
      • ButtonTests.cs5 KB
  • package.json1 KB
Show Code
Treeview.razor
<DwsTreeview Name="MyBadgeTree" Caption="Tree with badges" T="DemoFileNode"
             Items="@_tree"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             BadgeSelector="GetSizeBadge"
             ChildCountBadge="true"
             DefaultExpandedDepth="1" />

@code {
    private readonly List<DemoFileNode> _tree = BuildFileTree();

    // null: no badge. BadgeColorSelector picks the colour (Info by default).
    private static string? GetSizeBadge(DemoFileNode item) => item.Kind == "File" ? $"{item.SizeKb} KB" : null;
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Sorting

SortSelector (or SortComparer) sorts each subtree independently by a chosen value, in SortDirection order.

Sorted tree
  • docs
    • CHANGELOG.md
    • README.md
  • package.json
  • src
    • Components
      • Button.razor
      • Card.razor
    • Services
      • ApiClient.cs
  • tests
    • Unit
      • ButtonTests.cs
Show Code
Treeview.razor
<DwsButton Name="MySortToggle" OnClick="@(() => _sortDirection = _sortDirection == DwsSortDirection.Ascending ? DwsSortDirection.Descending : DwsSortDirection.Ascending)">
    Direction: @_sortDirection
</DwsButton>

<DwsTreeview Name="MySortedTree" Caption="Sorted tree" T="DemoFileNode"
             Items="@_tree"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             SortSelector="SortByName"
             SortDirection="@_sortDirection"
             DefaultExpandedDepth="1" />

@code {
    private readonly List<DemoFileNode> _tree = BuildFileTree();
    private DwsSortDirection _sortDirection = DwsSortDirection.Ascending;

    private static object? SortByName(DemoFileNode item) => item.Name;
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Appearance

Dense, Bordered and Hoverable control the overall appearance of the tree.

Styled tree
  • src
    • Components
      • Button.razor
      • Card.razor
    • Services
      • ApiClient.cs
  • docs
    • README.md
    • CHANGELOG.md
  • tests
    • Unit
      • ButtonTests.cs
  • package.json
Show Code
Treeview.razor
<DwsCheckBox Name="MyDense" Label="Dense" Checked="@_dense" CheckedChanged="@((bool? value) => _dense = value == true)" />
<DwsCheckBox Name="MyBordered" Label="Bordered" Checked="@_bordered" CheckedChanged="@((bool? value) => _bordered = value == true)" />
<DwsCheckBox Name="MyHoverable" Label="Hoverable" Checked="@_hoverable" CheckedChanged="@((bool? value) => _hoverable = value == true)" />

<DwsTreeview Name="MyStyledTree" Caption="Styled tree" T="DemoFileNode"
             Items="@_tree"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             Dense="@_dense"
             Bordered="@_bordered"
             Hoverable="@_hoverable"
             DefaultExpandedDepth="1" />

@code {
    private readonly List<DemoFileNode> _tree = BuildFileTree();
    private bool _dense;
    private bool _bordered = true;
    private bool _hoverable = true;
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Per-node CSS

NodeClass and NodeStyle add CSS classes and inline styles to a specific node's row; here files of 10 KB or more get a bold class.

Tree with per-node classes
  • src
    • Components
      • Button.razor
      • Card.razor
    • Services
      • ApiClient.cs
  • docs
    • README.md
    • CHANGELOG.md
  • tests
    • Unit
      • ButtonTests.cs
  • package.json
Show Code
Treeview.razor
<style>
    .dws-treeview-demo__large-file { font-weight: 600; }
</style>

<DwsTreeview Name="MyNodeClassTree" Caption="Tree with per-node classes" T="DemoFileNode"
             Items="@_tree"
             ItemKeySelector="@(item => item.Id)"
             ChildrenSelector="@(item => item.Children)"
             LabelSelector="@(item => item.Name)"
             NodeClass="GetLargeFileClass"
             DefaultExpandedDepth="1" />

@code {
    private readonly List<DemoFileNode> _tree = BuildFileTree();

    private static string GetLargeFileClass(DemoFileNode item) =>
        item.Kind == "File" && item.SizeKb >= 10 ? "dws-treeview-demo__large-file" : string.Empty;
}
Treeview.razor.cs
public sealed class DemoFileNode
{
    public int Id { get; init; }
    public string Name { get; set; } = string.Empty;
    public string Kind { get; set; } = "Folder"; // "Folder" or "File"
    public int SizeKb { get; set; }
    public List<DemoFileNode> Children { get; init; } = [];
}

private static List<DemoFileNode> BuildFileTree()
{
    int nextId = 1;
    DemoFileNode NewNode(string name, string kind, int sizeKb = 0) => new() { Id = nextId++, Name = name, Kind = kind, SizeKb = sizeKb };

    DemoFileNode components = NewNode("Components", "Folder");
    components.Children.Add(NewNode("Button.razor", "File", 4));
    components.Children.Add(NewNode("Card.razor", "File", 6));

    DemoFileNode src = NewNode("src", "Folder");
    src.Children.Add(components);

    DemoFileNode docs = NewNode("docs", "Folder");
    docs.Children.Add(NewNode("README.md", "File", 3));

    return [src, docs, NewNode("package.json", "File", 1)];
}

Interface-Description

Name Typ Default Description
SearchMatchCount int 0 The number of nodes currently matching search/filter.
AnyNodeLoading bool false Whether any node's children are currently loading.
Name Typ Parameters Description
ExpandNodeAsync Task Expands a node, loading its children first if not loaded yet.
CollapseNodeAsync Task Collapses a node.
ToggleNodeAsync Task Toggles a node between expanded and collapsed.
ExpandSubtreeAsync Task Expands a node and everything beneath it that is already materialised.
CollapseSubtreeAsync Task Collapses a node and everything beneath it.
ExpandAllAsync Task Expands every currently-materialised expandable node.
CollapseAllAsync Task Collapses every node.
ExpandToAsync Task<DwsTreeviewNode<T>?> Expands every ancestor of the node with a given key so it becomes visible.
GetExpandedKeys IReadOnlyCollection<object> The keys currently expanded.
SetExpandedKeysAsync Task Replaces the set of expanded keys.
EnsureChildrenLoadedAsync Task Loads a node's children immediately, without expanding it.
FindNode DwsTreeviewNode<T>? Finds a node by its key, or null if it is not currently materialised.
IsSelected bool Whether a node is currently selected.
GetCheckState bool? The tri-state checkbox state for a node.
SetSelectedAsync Task Sets a node's selection state directly.
ToggleSelectionAsync Task Toggles a node's selection state.
SelectRangeAsync Task Selects every node between two keys in rendered order.
SelectAllVisibleAsync Task Selects every currently visible, selectable node.
DeselectAllVisibleAsync Task Deselects every currently visible node.
ClearSelectionAsync Task Clears the whole selection.
StartRenameAsync Task Starts renaming a node inline.
CommitRenameAsync Task Validates and raises OnNodeRenamed for the node currently being renamed.
CancelRename void Cancels an in-progress rename without raising OnNodeRenamed.
FocusNodeAsync Task Moves keyboard focus to a node, scrolling it into view.
Name Typ Default Description
Items IEnumerable<T>? null The source items — roots when ChildrenSelector is set, the full flat list when ParentKeySelector is set.
ChildrenSelector Func<T, IEnumerable<T>?>? null Returns an item's children for a nested model.
ParentKeySelector Func<T, object?>? null Returns an item's parent key for a flat, self-referencing model.
ItemKeySelector Func<T, object> default! Stable identity for an item. Required for correct expansion/selection/persistence.
LabelSelector Func<T, string>? null The node's display text. Falls back to ToString().
MaxDepth int? null Caps how deep the hierarchy is materialised.
DataVersion int 0 Bump to force a full rebuild when Items was mutated in place.
DefaultExpandedDepth int? null Nodes at or above this depth start expanded, the first time they are built.
NodeTemplate RenderFragment<DwsTreeviewNodeContext<T>>? null Overrides how a node's content is rendered.
NodeActionsTemplate RenderFragment<DwsTreeviewNodeContext<T>>? null Custom action buttons rendered at the end of a node's row.
EmptyStateContent RenderFragment? null Shown instead of the default "no data" message.
IconSelector Func<T, string?>? null A leading icon for a node, independent of expanded/collapsed state.
ExpandedIconSelector Func<T, string?>? null Overrides the leading icon while an expandable node is expanded.
CollapsedIconSelector Func<T, string?>? null Overrides the leading icon while an expandable node is collapsed.
ExpanderExpandedIcon string chevron-down The expander chevron shown on an expanded node.
ExpanderCollapsedIcon string chevron-right The expander chevron shown on a collapsed node.
Selectable bool false Whether nodes can be selected at all.
MultiSelect bool false Whether more than one node can be selected at once.
Deselectable bool true Whether the last remaining selected node can be clicked again to clear the selection.
SelectionMode DwsTreeviewSelectionMode Independent Whether selecting a node also affects its ancestors/descendants via the checkbox.
ShowSelectionCheckbox bool false Shows a checkbox on every selectable node.
CanSelect Func<T, bool>? null Whether a given item may be selected at all.
SelectedKeys IReadOnlyCollection<object>? null The currently selected keys. Two-way bindable.
KeyboardNavigation bool true Enables the roving-tabindex treegrid-style keyboard map.
TypeAhead bool true A letter typed on a focused node moves to the next visible node whose label starts with it; letters typed quickly are matched as one text. Keys typed into a rename box or a field of a node template are left alone.
KeyboardPageSize int 10 How many rows Page Up/Page Down move.
ChildrenLoader Func<DwsTreeviewNode<T>, Task<IEnumerable<T>>>? null Fetches a node's children on demand, the first time it is expanded.
HasChildrenSelector Func<T, bool>? null Whether an item has children not yet loaded. Required for lazy loading to show an expander.
EnableNodeDragDrop bool false Enables dragging nodes to reorder or re-parent them.
CanDrag Func<T, bool>? null Whether a given item can be dragged.
CanAcceptDrop Func<DwsTreeviewNode<T>, DwsTreeviewNode<T>, DwsTreeDropPosition, bool>? null Whether a drop is accepted at a given position.
SearchText string? null Free-text search. Non-matching branches are hidden unless a descendant matches.
SearchSelector Func<T, string>? null The text searched against. Falls back to LabelSelector.
FilterPredicate Func<T, bool>? null An arbitrary node-visibility predicate, combined with SearchText.
AutoExpandToMatches bool true Expands ancestors of a search/filter match so it is visible.
EnableNodeRename bool false Allows double-click (or F2) to rename a node's label inline.
CanRename Func<T, bool>? null Whether a given item may be renamed.
RenameValidator Func<string, string?>? null Validates a proposed new label. Return an error message to reject it.
EnableContextMenu bool false Enables a context menu on nodes (a DwsContextMenu): right-click, a long press on a touch screen, the context menu key or Shift+F10.
ContextMenuItems List<DwsTreeviewContextMenuItem<T>> [] The context menu's entries.
SelectOnContextMenu bool true Selects a node when its context menu is opened.
Haptic DwsHapticFeedback DwsHapticFeedback.Selection Touch feedback (IDwsHapticService, while the app has haptics on) when a tap selects a node or ticks its checkbox. Played in the browser inside the tap. None switches it off.
BadgeSelector Func<T, string?>? null Text for a badge shown next to a node's label.
BadgeColorSelector Func<T, DwsColor>? null The badge's color. Defaults to Info.
ChildCountBadge bool false Shows an automatic badge with a node's direct child count.
NodeTooltipSelector Func<T, string?>? null A tooltip shown on hover over a node's label.
NodeClass Func<T, string>? null Additional CSS classes for a specific node's row.
NodeStyle Func<T, string>? null Additional inline styles for a specific node's row.
Hoverable bool true Highlights a node's row on hover.
Dense bool false Compacts row padding.
Bordered bool false Draws a border around the whole tree.
SortComparer IComparer<T>? null Compares two items for per-subtree sorting. Takes precedence over SortSelector.
SortSelector Func<T, object?>? null Returns the value each subtree is sorted by.
SortDirection DwsSortDirection Ascending The sort direction applied by SortComparer/SortSelector.
AnimateExpansion bool true Animates a node's children sliding in on expand.
ExpansionAnimationSpeed DwsAnimationSpeed Normal The expand/collapse animation's duration.
PersistState bool false Persists expansion/selection to localStorage, restored on the next load.
StorageKey string? null The storage key. Defaults to a key derived from Name.
PersistedState DwsTreeviewPersistedState All Which parts of the state PersistState saves.
Caption string? null An optional caption, used as the tree's accessible name instead of Name.
Name Typ Description
SelectedKeysChanged EventCallback<IReadOnlyCollection<object>> Raised whenever the selected key set changes.
OnSelect EventCallback<DwsTreeviewNode<T>> Raised when a node becomes selected.
OnDeselect EventCallback<DwsTreeviewNode<T>> Raised when a node becomes deselected.
OnExpand EventCallback<DwsTreeviewNode<T>> Raised when a node is expanded.
OnCollapse EventCallback<DwsTreeviewNode<T>> Raised when a node is collapsed.
OnChildrenLoaded EventCallback<DwsTreeviewNode<T>> Raised after a node's children finish loading.
OnNodeDragStart EventCallback<DwsTreeviewNode<T>> Raised when a drag starts.
OnNodeDrop EventCallback<DwsTreeviewNodeDropEventArgs<T>> Raised when a node is dropped.
OnSearchMatchesChanged EventCallback<int> Raised when the number of search/filter matches changes.
OnNodeRenamed EventCallback<DwsTreeviewRenameEventArgs<T>> Raised when a rename is committed.
OnContextMenuOpened EventCallback<DwsTreeviewNode<T>> Raised when a node's context menu opens.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.