Table of Contents

Class TreeViewItem

Namespace
Icy.UI.Controls
Assembly
IcyUI.dll

A row of a TreeView: a SelectorItem that knows its depth, whether it has children and is expanded, and whether it can be selected.

public class TreeViewItem : SelectorItem, INotifyPropertyChanging, IBindingTarget, INotifyPropertyChanged, INotifyFocusChanged, IContainerLayout
Inheritance
TreeViewItem
Implements
Inherited Members
Extension Methods

Remarks

The tree sets every row property each time the row is realized, because a pooled row is reused for another item with only its content's DataContext rebound.

Template parts:

Fields

ExpanderPartName

The name of the template part that shows the chevron.

public const string ExpanderPartName = "PART_Expander"

Field Value

string

IndentPartName

The name of the template part whose width indents the row.

public const string IndentPartName = "PART_Indent"

Field Value

string

Properties

Depth

Gets the row's depth: 0 for a root.

public int Depth { get; }

Property Value

int

HasChildren

Gets a value indicating whether the row's item has children.

public bool HasChildren { get; }

Property Value

bool

IsExpanded

Gets a value indicating whether the row's item is expanded.

public bool IsExpanded { get; }

Property Value

bool

IsSelectable

Gets a value indicating whether the row's item can be selected.

public bool IsSelectable { get; }

Property Value

bool

Methods

OnApplyTemplate()

Called once, every time Template changes (in either direction - applied, cleared, or switched to a different template), right after Chrome and every decoration/content property have been fully re-wired for the new state.

protected override void OnApplyTemplate()

Remarks

Does nothing by default. A subclass that reaches into its own visual tree by reference - e.g. Slider wiring its drag logic directly to its thumb element - overrides this to call GetTemplateChild<T>(string) and repoint that reference to whatever the new Template (or, when reverting, the fresh default Border) actually provides, instead of hardcoding it once at construction. This is what actually makes a control "template-safe": until a control overrides this appropriately, applying a custom Template to it silently orphans whatever elements its own code still holds direct references to.

OnTap()

Invoked by Canvas when this element (or a descendant) is the target of a completed tap (see Tap). The base implementation does nothing.

protected override void OnTap()

Remarks

Called on the hit-tested element and every one of its ancestors (bubbling, with no "handled" flag in v1) - so e.g. a Button reacts to a tap on its label TextBlock just as it would to a tap on its own background.

Events

ExpanderTapped

Occurs when the row's chevron is tapped. The same tap doesn't raise Tapped.

public event EventHandler? ExpanderTapped

Event Type

EventHandler