HypernovaDesktop Components · docs
Binarymission
WPF › Tree List View › BinaryTreeListViewItem

BinaryTreeListViewItem

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Controls.TreeControls

One row of a BinaryTreeListView: its cells, its expander and the rows beneath it.

public class BinaryTreeListViewItem : TreeViewItem

Inherits from / implements: TreeViewItem

Remarks

A bound tree creates its rows itself, one for each item, and you seldom meet this class except in BinaryTreeListView.MultiSelectedItems. To build a tree in code, create one for each row: put the row object – any object with the properties the columns bind to – in HeaderedItemsControl.Header, and add the rows beneath it to ItemsControl.Items.

Everything a TreeViewItem offers works here: TreeViewItem.IsExpanded, TreeViewItem.IsSelected, TreeViewItem.ExpandSubtree, FrameworkElement.ToolTip and the rest.

Examples

BinaryTreeListViewItem europe = new BinaryTreeListViewItem
{
    Header = new Region { Name = "Europe", Revenue = 4200000m },
    IsExpanded = true,
    ToolTip = "Revenue for the year to date"
};

europe.Items.Add(new BinaryTreeListViewItem { Header = new Region { Name = "France",  Revenue = 1300000m } });
europe.Items.Add(new BinaryTreeListViewItem { Header = new Region { Name = "Germany", Revenue = 1900000m } });

regionsTree.Items.Add(europe);

See also

Members at a glance

Properties
LevelGets how deep in the tree this row is.
Methods
GetContainerForItemOverrideCreates the row that shows one bound child item: a BinaryTreeListViewItem.
IsItemItsOwnContainerOverrideTells the row whether a child item is already a row, and so needs no row of its own.
OnItemsChangedRedraws this row and every row beneath it when its children change, because a row's connecting lines depend on whether another row follows it at its own level and at each level above.

Properties

Level

public int Level

Gets how deep in the tree this row is.

Value
0 for a top-level row, 1 for its children, 2 for theirs, and so on.
Remarks

The level is worked out the first time it is read, from the row's place in the tree, and remembered.

Methods

GetContainerForItemOverride

protected override DependencyObject GetContainerForItemOverride()

Creates the row that shows one bound child item: a BinaryTreeListViewItem.

Returns

IsItemItsOwnContainerOverride

protected override bool IsItemItsOwnContainerOverride(object item)

Tells the row whether a child item is already a row, and so needs no row of its own.

Parameters
item
An entry in this row's ItemsControl.Items.
Returns

true when item is a BinaryTreeListViewItem.

OnItemsChanged

protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)

Redraws this row and every row beneath it when its children change, because a row's connecting lines depend on whether another row follows it at its own level and at each level above.

Parameters
e
What changed in the collection.
Remarks

A derived class that overrides this should call the base implementation.