Skip to content

TreeItemWidget ​

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A focusable tree item with label and optional icon. Supports lazy loading of children via OnExpanding callback.

csharp
public sealed record TreeItemWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<TreeItemWidget>

Inheritance ​

Object → Hex1bWidget → TreeItemWidget

Implements ​

Constructors ​

TreeItemWidget(string) ​

A focusable tree item with label and optional icon. Supports lazy loading of children via OnExpanding callback.

Parameters:

  • Label (String): The display label for this tree item.
csharp
public TreeItemWidget(string Label)

Properties ​

HasChildren ​

Hint that this item has children even if Children is empty. Used to show expand indicator for lazy-loaded items.

Returns: Boolean

csharp
public bool HasChildren { get; init; }

IsExpanded ​

Whether this item is expanded to show children. Default is false (collapsed).

Returns: Boolean

csharp
public bool IsExpanded { get; init; }

IsLoading ​

Whether this item is currently loading children. Default is false. When true, displays an animated spinner instead of the expand indicator.

Returns: Boolean

csharp
public bool IsLoading { get; init; }

IsSelected ​

Whether this item is selected (for multi-select mode). Default is false.

Returns: Boolean

csharp
public bool IsSelected { get; init; }

Label ​

The display label for this tree item.

Returns: String

csharp
public string Label { get; init; }

Methods ​

Children(params TreeItemWidget[]) ​

Sets the child items. Also sets HasChildren to true if children are provided.

Parameters:

  • children (TreeItemWidget[]):

Returns: TreeItemWidget

csharp
public TreeItemWidget Children(params TreeItemWidget[] children)

Data<T>(T) ​

Associates typed data with this item. Retrieve with .

Parameters:

  • data (<T>): The data to associate with this item.

Returns: TreeItemWidget

A new TreeItemWidget with the data set.

csharp
public TreeItemWidget Data<T>(T data)

Expanded(bool) ​

Sets whether this item is initially expanded.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget Expanded(bool expanded = true)

Icon(string) ​

Sets the icon/emoji prefix for this item.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget Icon(string icon)

Loading(bool) ​

Sets whether this item is currently loading children. When true, displays an animated spinner instead of the expand indicator.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget Loading(bool loading = true)

OnActivated(Action<TreeItemActivatedEventArgs>) ​

Sets a synchronous handler called when this item is activated (Enter key).

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnActivated(Action<TreeItemActivatedEventArgs> handler)

OnActivated(Func<TreeItemActivatedEventArgs, Task>) ​

Sets an asynchronous handler called when this item is activated (Enter key or double-click).

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnActivated(Func<TreeItemActivatedEventArgs, Task> handler)

OnClicked(Action<TreeItemClickedEventArgs>) ​

Sets a synchronous handler called when this item is clicked (single-click).

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnClicked(Action<TreeItemClickedEventArgs> handler)

OnClicked(Func<TreeItemClickedEventArgs, Task>) ​

Sets an asynchronous handler called when this item is clicked (single-click).

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnClicked(Func<TreeItemClickedEventArgs, Task> handler)

OnCollapsed(Action<TreeItemCollapsedEventArgs>) ​

Sets a synchronous handler called when this item is collapsed.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnCollapsed(Action<TreeItemCollapsedEventArgs> handler)

OnCollapsed(Func<TreeItemCollapsedEventArgs, Task>) ​

Sets an asynchronous handler called when this item is collapsed.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnCollapsed(Func<TreeItemCollapsedEventArgs, Task> handler)

OnExpanded(Action<TreeItemExpandedEventArgs>) ​

Sets a synchronous handler called after this item is expanded.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnExpanded(Action<TreeItemExpandedEventArgs> handler)

OnExpanded(Func<TreeItemExpandedEventArgs, Task>) ​

Sets an asynchronous handler called after this item is expanded.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnExpanded(Func<TreeItemExpandedEventArgs, Task> handler)

OnExpanding(Func<TreeItemExpandingEventArgs, IEnumerable<TreeItemWidget>>) ​

Sets a synchronous handler for lazy loading children when the item is expanded. Also sets HasChildren to true.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnExpanding(Func<TreeItemExpandingEventArgs, IEnumerable<TreeItemWidget>> handler)

OnExpanding(Func<TreeItemExpandingEventArgs, Task<IEnumerable<TreeItemWidget>>>) ​

Sets an asynchronous handler for lazy loading children when the item is expanded. Also sets HasChildren to true.

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget OnExpanding(Func<TreeItemExpandingEventArgs, Task<IEnumerable<TreeItemWidget>>> handler)

Selected(bool) ​

Sets whether this item is selected (for multi-select mode).

Parameters:

Returns: TreeItemWidget

csharp
public TreeItemWidget Selected(bool selected = true)

Fields ​

ActivateActionId ​

Action ID for activating the tree item.

Returns: ActionId

csharp
public static readonly ActionId ActivateActionId

CollapseActionId ​

Action ID for collapsing the tree item.

Returns: ActionId

csharp
public static readonly ActionId CollapseActionId

ExpandActionId ​

Action ID for expanding the tree item.

Returns: ActionId

csharp
public static readonly ActionId ExpandActionId

ToggleActionId ​

Action ID for toggling selection or expand state.

Returns: ActionId

csharp
public static readonly ActionId ToggleActionId

Released under the MIT License.