Table of Contents

Class TreeViewNode

Namespace
Icy.UI.Controls
Assembly
IcyUI.dll

A ready-made data item for a TreeView: a header, child nodes, and per-node expansion and selectability. Lets a static tree be written directly in markup.

[ContentProperty("Children")]
public class TreeViewNode : INotifyPropertyChanged
Inheritance
TreeViewNode
Implements
Inherited Members
Extension Methods

Remarks

Children is the content property, so nested <TreeViewNode> elements need no wrapper:

<TreeView>
  <TreeViewNode Header="Basics" IsSelectable="False" IsExpanded="True">
    <TreeViewNode Header="Controls"/>
  </TreeViewNode>
</TreeView>

A TreeView reads IsExpanded as the node's expansion state and keeps it in step both ways, and treats IsSelectable as the node's selectability unless IsItemSelectable is set. Without an item template, a row shows ToString().

Constructors

TreeViewNode()

Initializes a new instance of the TreeViewNode class with no header.

public TreeViewNode()

TreeViewNode(object?)

Initializes a new instance of the TreeViewNode class.

public TreeViewNode(object? header)

Parameters

header object

The header to show.

Properties

Children

Gets the child nodes. A TreeView follows changes to this collection while the node is visible.

public ObservableCollection<TreeViewNode> Children { get; }

Property Value

ObservableCollection<TreeViewNode>

Header

Gets or sets what the node's row shows.

public object? Header { get; set; }

Property Value

object

IsExpanded

Gets or sets a value indicating whether the node shows its children. Defaults to false.

public bool IsExpanded { get; set; }

Property Value

bool

IsSelectable

Gets or sets a value indicating whether the node can be selected. Defaults to true. Tapping a non-selectable node with children opens or closes it instead.

public bool IsSelectable { get; set; }

Property Value

bool

Tag

Gets or sets any data the application wants to attach to the node.

public object? Tag { get; set; }

Property Value

object

Methods

ToString()

Returns the text of Header.

public override string ToString()

Returns

string

Header's text, or an empty string when there is none.

Events

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler