HypernovaDesktop Components · docs
Binarymission
WPFTree List View › BinaryTreeListView

BinaryTreeListView

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

A custom TreeView derived class that renders and manages its data in several columns, each column's row being rendered in an hierarchical manner.

public class BinaryTreeListView : TreeView

Inherits from / implements: TreeView

Remarks

The control is very simple to use. All that you will need to do typically is:
1. Create an instance of BinaryTreeListView control.

2. Create as many needed instances of GridViewColumns.

3. Set the ItemsSource property with the data-source that will feed the data for this control.
This can come from any sources like: XML, CLR objects/collections, result of LINQ queries, DataTable, simple CLR arrays, etc.

4. Specify which column you would like the control to render as a tree-list column. TO do this set the TreeListViewColumnIndex or TreeListViewColumn properties with relevant value.

Note that you can also add rows pro grammatically. It is not a necessity that the data comes from DataBinding / data-source.

That is all to it. Run the application and you will see your data in a hierarchical manner using a TreeListView style.

You could also setup other properties in the control to enhance the user experience.

Members at a glance

BinaryTreeListViewInitializes a new instance of the BinaryTreeListView class.
CollapseButtonImageGets or sets the collapse button image.
ColumnsGets the columns collection in the control.
ExpandButtonImageGets or sets the expand button image.
ExpandCollapseBorderBrushGets or sets the expand / collapse border brush.
ExpandCollapseButtonImageStretchGets or sets the expand collapse button image stretch.
ExpandCollapseControlFillBrushGets or sets the expand / collapse glyph fill brush.
ExpandCollapsePlusMinusBrushGets or sets the expand / collapse plus / minus brush.
IsMultiSelectionEnabledGets or sets whether multi-selection of notes is enabled.
IsNodesConnectingLineVisibleGets or sets a value indicating whether the control should draw the nodes connecting line.
IsShiftMultiSelectionEnabledGets or sets whether the SHIFT + selection is enabled for multi-selection of nodes. By default this value is false.
MultiSelectedItemsGets the multi-selected items.
NodesConnectingLineBrushGets or sets the nodes connecting line brush.
RenderCollapseExpandVisualAlwaysInTheFirstColumnGets or sets a value indicating whether to always render the first column as the tree-list view colum.
SelectionBackgroundBrushGets or sets the node/row item "selection" background brush.
SelectionForegroundBrushGets or sets the node/row item "selection" foreground brush.
TreeListViewColumnGets or sets the column object that will be rendered as a treelistview column - i.e. the column that will be able to expand/collapse its child nodes.
TreeListViewColumnIndexGets or sets the column index that will be rendered as a treelistview column - i.e. the column that will be able to expand/collapse its child nodes.
TreeListViewItemIsRenderedWithRoundedCornerGets or sets a value indicating whether the tree list view item is rendered with rounded corner.
CollapseAllNodesCollapses all nodes.
ExpandAllNodesExpands all nodes.
ExpandNodeByIndexExpands the index of the node by.
ExpandNodesByIndicesExpands the nodes by indices.
GetContainerForItemOverrideCreates the container that one item is shown in, which for this control is a BinaryTreeListViewItem.
IsItemItsOwnContainerOverrideReports whether an item can be shown as it stands, without being wrapped in a container of its own.
OnItemsChangedRaises the ItemsChanged event. BinaryTreeListView overrides it so the control's own handling runs alongside the base behavior.
SelectNodeByIndexSelects the index of the node by.
SelectNodesByIndicesSelects several nodes at once by their positions in the list.
CollapseButtonImagePropertyIdentifies the CollapseButtonImage dependency property.
ExpandButtonImagePropertyIdentifies the ExpandButtonImage dependency property.
ExpandCollapseBorderBrushPropertyIdentifies the ExpandCollapseBorderBrush dependency property.
ExpandCollapseButtonImageStretchPropertyIdentifies the ExpandCollapseButtonImageStretch dependency property.
ExpandCollapseControlFillBrushPropertyIdentifies the ExpandCollapseControlFillBrush dependency property.
ExpandCollapsePlusMinusBrushPropertyIdentifies the ExpandCollapsePlusMinusBrush dependency property.
IsMultiSelectionEnabledPropertyIdentifies the IsMultiSelectionEnabled dependency property.
IsNodesConnectingLineVisiblePropertyIdentifies the IsNodesConnectingLineVisible dependency property.
IsShiftMultiSelectionEnabledPropertyIdentifies the IsShiftMultiSelectionEnabled dependency property.
NodesConnectingLineBrushPropertyIdentifies the NodesConnectingLineBrush dependency property.
RenderCollapseExpandVisualAlwaysInTheFirstColumnPropertyIdentifies the RenderCollapseExpandVisualAlwaysInTheFirstColumn dependency property.
SelectionBackgroundBrushPropertyIdentifies the SelectionBackgroundBrush dependency property.
SelectionForegroundBrushPropertyIdentifies the SelectionForegroundBrush dependency property.
TreeListViewColumnIndexPropertyIdentifies the TreeListViewColumnIndex dependency property.
TreeListViewColumnPropertyIdentifies the TreeListViewColumn dependency property.
TreeListViewItemIsRenderedWithRoundedCornerPropertyIdentifies the TreeListViewItemIsRenderedWithRoundedCorner dependency property.

Constructors

BinaryTreeListView

public BinaryTreeListView()

Initializes a new instance of the BinaryTreeListView class.

Properties

CollapseButtonImage

public ImageSource CollapseButtonImage

Gets or sets the collapse button image.

Columns

public GridViewColumnCollection Columns

Gets the columns collection in the control.

ExpandButtonImage

public ImageSource ExpandButtonImage

Gets or sets the expand button image.

ExpandCollapseBorderBrush

public Brush ExpandCollapseBorderBrush

Gets or sets the expand / collapse border brush.

ExpandCollapseButtonImageStretch

public Stretch ExpandCollapseButtonImageStretch

Gets or sets the expand collapse button image stretch.

Value. The expand collapse button image stretch.

ExpandCollapseControlFillBrush

public Brush ExpandCollapseControlFillBrush

Gets or sets the expand / collapse glyph fill brush.

ExpandCollapsePlusMinusBrush

public Brush ExpandCollapsePlusMinusBrush

Gets or sets the expand / collapse plus / minus brush.

IsMultiSelectionEnabled

public bool IsMultiSelectionEnabled

Gets or sets whether multi-selection of notes is enabled.

By default, CTRL + click based multi-selection is enabled if you set this property to true.If you also need Shift + Selection for multi-selection, then please set IsShiftMultiSelectionEnabled to True.

IsNodesConnectingLineVisible

public bool IsNodesConnectingLineVisible

Gets or sets a value indicating whether the control should draw the nodes connecting line.

IsShiftMultiSelectionEnabled

public bool IsShiftMultiSelectionEnabled

Gets or sets whether the SHIFT + selection is enabled for multi-selection of nodes. By default this value is false.

MultiSelectedItems

public List<BinaryTreeListViewItem> MultiSelectedItems

Gets the multi-selected items.

Value. The multi selected items.

NodesConnectingLineBrush

public SolidColorBrush NodesConnectingLineBrush

Gets or sets the nodes connecting line brush.

Value. The nodes connecting line brush.

RenderCollapseExpandVisualAlwaysInTheFirstColumn

public bool RenderCollapseExpandVisualAlwaysInTheFirstColumn

Gets or sets a value indicating whether to always render the first column as the tree-list view colum.

SelectionBackgroundBrush

public Brush SelectionBackgroundBrush

Gets or sets the node/row item "selection" background brush.

SelectionForegroundBrush

public Brush SelectionForegroundBrush

Gets or sets the node/row item "selection" foreground brush.

TreeListViewColumn

public GridViewColumn TreeListViewColumn

Gets or sets the column object that will be rendered as a treelistview column - i.e. the column that will be able to expand/collapse its child nodes.

Value. The tree list view column.

TreeListViewColumnIndex

public int TreeListViewColumnIndex

Gets or sets the column index that will be rendered as a treelistview column - i.e. the column that will be able to expand/collapse its child nodes.

Value. The tree list view column.

TreeListViewItemIsRenderedWithRoundedCorner

public bool TreeListViewItemIsRenderedWithRoundedCorner

Gets or sets a value indicating whether the tree list view item is rendered with rounded corner.

Methods

CollapseAllNodes

public void CollapseAllNodes()

Collapses all nodes.

ExpandAllNodes

public void ExpandAllNodes(bool shouldScrollBackToTop)

Expands all nodes.

shouldScrollBackToTop
if set to true the control should scroll back to the top item in the tree-listview instance.

ExpandNodeByIndex

public void ExpandNodeByIndex(int index)

Expands the index of the node by.

index
The index.

ExpandNodesByIndices

public void ExpandNodesByIndices(IEnumerable<int> indices)

Expands the nodes by indices.

indices
The indices.

GetContainerForItemOverride

protected override DependencyObject GetContainerForItemOverride()

Creates the container that one item is shown in, which for this control is a BinaryTreeListViewItem.

IsItemItsOwnContainerOverride

protected override bool IsItemItsOwnContainerOverride(object item)

Reports whether an item can be shown as it stands, without being wrapped in a container of its own.

OnItemsChanged

protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

Raises the ItemsChanged event. BinaryTreeListView overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

SelectNodeByIndex

public void SelectNodeByIndex(int index)

Selects the index of the node by.

index
The index.

SelectNodesByIndices

public void SelectNodesByIndices(IEnumerable<int> indices)

Selects several nodes at once by their positions in the list.

indices
The zero-based positions to select. An empty sequence selects nothing.

Fields

CollapseButtonImageProperty

public static readonly DependencyProperty CollapseButtonImageProperty

Identifies the CollapseButtonImage dependency property.

ExpandButtonImageProperty

public static readonly DependencyProperty ExpandButtonImageProperty

Identifies the ExpandButtonImage dependency property.

ExpandCollapseBorderBrushProperty

public static DependencyProperty ExpandCollapseBorderBrushProperty

Identifies the ExpandCollapseBorderBrush dependency property.

ExpandCollapseButtonImageStretchProperty

public static readonly DependencyProperty ExpandCollapseButtonImageStretchProperty

Identifies the ExpandCollapseButtonImageStretch dependency property.

ExpandCollapseControlFillBrushProperty

public static DependencyProperty ExpandCollapseControlFillBrushProperty

Identifies the ExpandCollapseControlFillBrush dependency property.

ExpandCollapsePlusMinusBrushProperty

public static DependencyProperty ExpandCollapsePlusMinusBrushProperty

Identifies the ExpandCollapsePlusMinusBrush dependency property.

IsMultiSelectionEnabledProperty

public static readonly DependencyProperty IsMultiSelectionEnabledProperty = DependencyProperty.Register("IsMultiSelectionEnabled", typeof(bool), typeof(BinaryTreeListView), new UIPropertyMetadata(false, (o, e)

Identifies the IsMultiSelectionEnabled dependency property.

IsNodesConnectingLineVisibleProperty

public static readonly DependencyProperty IsNodesConnectingLineVisibleProperty

Identifies the IsNodesConnectingLineVisible dependency property.

IsShiftMultiSelectionEnabledProperty

public static readonly DependencyProperty IsShiftMultiSelectionEnabledProperty = DependencyProperty.Register("IsShiftMultiSelectionEnabled", typeof(bool), typeof(BinaryTreeListView), new UIPropertyMetadata(false, (o, e)

Identifies the IsShiftMultiSelectionEnabled dependency property.

NodesConnectingLineBrushProperty

public static readonly DependencyProperty NodesConnectingLineBrushProperty

Identifies the NodesConnectingLineBrush dependency property.

RenderCollapseExpandVisualAlwaysInTheFirstColumnProperty

public static readonly DependencyProperty RenderCollapseExpandVisualAlwaysInTheFirstColumnProperty

Identifies the RenderCollapseExpandVisualAlwaysInTheFirstColumn dependency property.

SelectionBackgroundBrushProperty

public static DependencyProperty SelectionBackgroundBrushProperty

Identifies the SelectionBackgroundBrush dependency property.

SelectionForegroundBrushProperty

public static readonly DependencyProperty SelectionForegroundBrushProperty

Identifies the SelectionForegroundBrush dependency property.

TreeListViewColumnIndexProperty

public static readonly DependencyProperty TreeListViewColumnIndexProperty = DependencyProperty.Register("TreeListViewColumnIndex", typeof(int), typeof(BinaryTreeListView), new UIPropertyMetadata(-1, (o, args)

Identifies the TreeListViewColumnIndex dependency property.

TreeListViewColumnProperty

public static readonly DependencyProperty TreeListViewColumnProperty

Identifies the TreeListViewColumn dependency property.

TreeListViewItemIsRenderedWithRoundedCornerProperty

public static DependencyProperty TreeListViewItemIsRenderedWithRoundedCornerProperty

Identifies the TreeListViewItemIsRenderedWithRoundedCorner dependency property.