BinaryTreeListView
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 partial class BinaryTreeListView : TreeView
Inherits from / implements: TreeView
Remarks
To use it: add GridViewColumns to Columns, set ItemsSource (or add BinaryTreeListViewItems), and say which column carries the tree with TreeListViewColumn or TreeListViewColumnIndex. How this control works. It is a TreeView whose rows are laid out like a ListView in grid view. The control owns one GridViewColumnCollection; the heading row is a GridViewHeaderRowPresenter over it, and every row, at every depth, draws its cells with a BinaryTreeListViewNodePresenter - a GridViewRowPresenter over the same collection - so the columns line up across levels and follow any resize or reorder of the headings. The node presenter indents only the tree column's cell by the row's depth, puts the expander there, and draws the connecting lines and row separators itself; the other columns are plain cells. The tree column follows the column, not the index. TreeListViewColumn is what the rows go by; TreeListViewColumnIndex is kept in step with it, including when the user drags that column to a new position, and an index set before the columns exist is taken up as soon as a column arrives at it. Sorting (AllowsColumnSorting) sorts every branch, not just the top level: bound branches through their view's sort descriptions, unbound ones by reordering the item containers. Row striping is laid again after a sort, an expand or a collapse. Multi-selection is built on the tree view's single selection: the tree view selects the row clicked, and a handler on SelectedItemChanged keeps MultiSelectedItems - Ctrl toggles a row, Shift takes the top-level rows from the last plain click to the row clicked. Rows it selects itself are selected with the tree view's internal IsSelectionChangeActive set, read by reflection, so that the tree view does not deselect each one as the next is selected; without that property (a future framework), the multi-selection features stay off.
Members at a glance
BinaryTreeListView | Initializes a new instance of the BinaryTreeListView class. |
AllowsColumnReorder | Gets or sets a value indicating whether a column can be moved by dragging its heading. |
AllowsColumnSorting | Gets or sets a value indicating whether clicking a column heading sorts the rows by that column. |
AlternateRowBackgroundBrush | Gets or sets the background given to the rows in odd positions on screen. |
CollapseButtonImage | Gets or sets the collapse button image. |
ColumnHeaderBackgroundBrush | Gets or sets the fill behind the column headings. |
ColumnHeaderBorderBrush | Gets or sets the colour of the edge drawn to the right of and under each column heading. |
ColumnHeaderForegroundBrush | Gets or sets the colour the column headings' text is drawn in. |
ColumnHeaderHeight | Gets or sets how tall the column headings are drawn. |
ColumnHeaderHoverBackgroundBrush | Gets or sets the fill behind a column heading the pointer is over. |
ColumnHeaderPressedBackgroundBrush | Gets or sets the fill behind a column heading that is being pressed. |
ColumnReorderIndicatorBrush | Gets or sets the colour of the line that shows where a dragged column will be dropped, and of the wash over the column being dragged. |
Columns | Gets the columns collection in the control. |
ExpandButtonImage | Gets or sets the expand button image. |
ExpandCollapseBorderBrush | Gets or sets the expand / collapse border brush. |
ExpandCollapseButtonImageStretch | Gets or sets the expand collapse button image stretch. |
ExpandCollapseControlFillBrush | Gets or sets the expand / collapse glyph fill brush. |
ExpandCollapsePlusMinusBrush | Gets or sets the expand / collapse plus / minus brush. |
ExpanderGlyph | Gets or sets the shape the expand / collapse control is drawn as. |
InactiveSelectionBackgroundBrush | Gets or sets the background of a selected row while the control does not have focus. |
InactiveSelectionForegroundBrush | Gets or sets the text colour of a selected row while the control does not have focus. |
IsMultiSelectionEnabled | Gets or sets whether multi-selection of notes is enabled. |
IsNodesConnectingLineDotted | Gets or sets a value indicating whether the lines that join the nodes are drawn as dashes rather than solid. |
IsNodesConnectingLineVisible | Gets or sets a value indicating whether the control should draw the nodes connecting line. |
IsShiftMultiSelectionEnabled | Gets or sets whether the SHIFT + selection is enabled for multi-selection of nodes. By default this value is false. |
MouseOverBackgroundBrush | Gets or sets the row background drawn while the pointer is over it. |
MouseOverForegroundBrush | Gets or sets the row foreground drawn while the pointer is over it. |
MultiSelectedItems | Gets the multi-selected items. |
NodesConnectingLineBrush | Gets or sets the nodes connecting line brush. |
RenderCollapseExpandVisualAlwaysInTheFirstColumn | Gets or sets a value indicating whether to always render the first column as the tree-list view colum. |
RowBackgroundBrush | Gets or sets the background given to the rows in even positions on screen. |
RowSeparatorBrush | Gets or sets the brush the line under each row is drawn in. No line is drawn while this is null , which is what it starts as. |
SelectionBackgroundBrush | Gets or sets the node/row item "selection" background brush. |
SelectionForegroundBrush | Gets or sets the node/row item "selection" foreground brush. |
SortDirection | Gets which way round SortedColumn is sorted. |
SortGlyphBrush | Gets or sets the colour the sort arrow over the column heading is drawn in. |
SortedColumn | Gets the column the rows are currently in order of, or null when they are in the order they were added. |
Theme | Gets or sets the built-in colour scheme the control draws itself in. |
TreeListViewColumn | Gets or sets the column that carries the tree - the expander, the indent and the connecting lines. Every other column draws as a plain cell, and the nodes keep their parents and children whichever column this is. |
TreeListViewColumnIndex | Gets or sets the position of the column that carries the tree. |
TreeListViewItemIsRenderedWithRoundedCorner | Gets or sets a value indicating whether the tree list view item is rendered with rounded corner. |
ClearColumnSort | Stops sorting by a column. |
CollapseAllNodes | Collapses all nodes. |
ExpandAllNodes | Expands all nodes. |
ExpandNodeByIndex | Expands the index of the node by. |
ExpandNodesByIndices | Expands the nodes by indices. |
GetContainerForItemOverride | Creates the container that one item is shown in, which for this control is a BinaryTreeListViewItem. |
GetSortMemberPath | Gets the property a column is sorted by. |
IsItemItsOwnContainerOverride | Reports whether an item can be shown as it stands, without being wrapped in a container of its own. |
OnApplyTemplate | Applies the control's template. |
OnItemsChanged | Raises the ItemsChanged event. BinaryTreeListView overrides it so the control's own handling runs alongside the base behavior. |
RefreshRowDecorations | Draws every row on screen again. |
RefreshRowStriping | Lays the alternating row backgrounds again, in the order the rows are drawn. |
SelectNodeByIndex | Selects the index of the node by. |
SelectNodesByIndices | Selects several nodes at once by their positions in the list. |
SetSortMemberPath | Sets the property a column is sorted by. |
SortByColumn | Puts every branch of the tree in order of one column. |
ColumnReordered | Occurs after a column has been moved by dragging its heading. |
ColumnSorted | Occurs after the rows have been put in order of a column. |
AllowsColumnReorderProperty | Identifies the AllowsColumnReorder dependency property. |
AllowsColumnSortingProperty | Identifies the AllowsColumnSorting dependency property. |
AlternateRowBackgroundBrushProperty | Identifies the AlternateRowBackgroundBrush dependency property. |
CollapseButtonImageProperty | Identifies the CollapseButtonImage dependency property. |
ColumnHeaderBackgroundBrushProperty | Identifies the ColumnHeaderBackgroundBrush dependency property. |
ColumnHeaderBorderBrushProperty | Identifies the ColumnHeaderBorderBrush dependency property. |
ColumnHeaderForegroundBrushProperty | Identifies the ColumnHeaderForegroundBrush dependency property. |
ColumnHeaderHeightProperty | Identifies the ColumnHeaderHeight dependency property. |
ColumnHeaderHoverBackgroundBrushProperty | Identifies the ColumnHeaderHoverBackgroundBrush dependency property. |
ColumnHeaderPressedBackgroundBrushProperty | Identifies the ColumnHeaderPressedBackgroundBrush dependency property. |
ColumnReorderIndicatorBrushProperty | Identifies the ColumnReorderIndicatorBrush dependency property. |
ExpandButtonImageProperty | Identifies the ExpandButtonImage dependency property. |
ExpandCollapseBorderBrushProperty | Identifies the ExpandCollapseBorderBrush dependency property. |
ExpandCollapseButtonImageStretchProperty | Identifies the ExpandCollapseButtonImageStretch dependency property. |
ExpandCollapseControlFillBrushProperty | Identifies the ExpandCollapseControlFillBrush dependency property. |
ExpandCollapsePlusMinusBrushProperty | Identifies the ExpandCollapsePlusMinusBrush dependency property. |
ExpanderGlyphProperty | Identifies the ExpanderGlyph dependency property. |
InactiveSelectionBackgroundBrushProperty | Identifies the InactiveSelectionBackgroundBrush dependency property. |
InactiveSelectionForegroundBrushProperty | Identifies the InactiveSelectionForegroundBrush dependency property. |
IsMultiSelectionEnabledProperty | Identifies the IsMultiSelectionEnabled dependency property. |
IsNodesConnectingLineDottedProperty | Identifies the IsNodesConnectingLineDotted dependency property. |
IsNodesConnectingLineVisibleProperty | Identifies the IsNodesConnectingLineVisible dependency property. |
IsShiftMultiSelectionEnabledProperty | Identifies the IsShiftMultiSelectionEnabled dependency property. |
MouseOverBackgroundBrushProperty | Identifies the MouseOverBackgroundBrush dependency property. |
MouseOverForegroundBrushProperty | Identifies the MouseOverForegroundBrush dependency property. |
NodesConnectingLineBrushProperty | Identifies the NodesConnectingLineBrush dependency property. |
RenderCollapseExpandVisualAlwaysInTheFirstColumnProperty | Identifies the RenderCollapseExpandVisualAlwaysInTheFirstColumn dependency property. |
RowBackgroundBrushProperty | Identifies the RowBackgroundBrush dependency property. |
RowSeparatorBrushProperty | Identifies the RowSeparatorBrush dependency property. |
SelectionBackgroundBrushProperty | Identifies the SelectionBackgroundBrush dependency property. |
SelectionForegroundBrushProperty | Identifies the SelectionForegroundBrush dependency property. |
SortDirectionProperty | Identifies the SortDirection dependency property. |
SortGlyphBrushProperty | Identifies the SortGlyphBrush dependency property. |
SortMemberPathProperty | Identifies the SortMemberPath attached property, which names the property to sort a column by when the column draws its cells with a template and so has no DisplayMemberBinding to read one from. |
SortedColumnProperty | Identifies the SortedColumn dependency property. |
ThemeProperty | Identifies the Theme dependency property. |
TreeListViewColumnIndexProperty | Identifies the TreeListViewColumnIndex dependency property. |
TreeListViewColumnProperty | Identifies the TreeListViewColumn dependency property. |
TreeListViewItemIsRenderedWithRoundedCornerProperty | Identifies the TreeListViewItemIsRenderedWithRoundedCorner dependency property. |
Constructors
BinaryTreeListView
Initializes a new instance of the BinaryTreeListView class.
Properties
AllowsColumnReorder
Gets or sets a value indicating whether a column can be moved by dragging its heading.
AllowsColumnSorting
Gets or sets a value indicating whether clicking a column heading sorts the rows by that column.
AlternateRowBackgroundBrush
Gets or sets the background given to the rows in odd positions on screen.
CollapseButtonImage
Gets or sets the collapse button image.
ColumnHeaderBackgroundBrush
Gets or sets the fill behind the column headings.
ColumnHeaderBorderBrush
Gets or sets the colour of the edge drawn to the right of and under each column heading.
ColumnHeaderForegroundBrush
Gets or sets the colour the column headings' text is drawn in.
ColumnHeaderHeight
Gets or sets how tall the column headings are drawn.
ColumnHeaderHoverBackgroundBrush
Gets or sets the fill behind a column heading the pointer is over.
ColumnHeaderPressedBackgroundBrush
Gets or sets the fill behind a column heading that is being pressed.
ColumnReorderIndicatorBrush
Gets or sets the colour of the line that shows where a dragged column will be dropped, and of the wash over the column being dragged.
Columns
Gets the columns collection in the control.
ExpandButtonImage
Gets or sets the expand button image.
ExpandCollapseBorderBrush
Gets or sets the expand / collapse border brush.
ExpandCollapseButtonImageStretch
Gets or sets the expand collapse button image stretch.
Value. The expand collapse button image stretch.
ExpandCollapseControlFillBrush
Gets or sets the expand / collapse glyph fill brush.
ExpandCollapsePlusMinusBrush
Gets or sets the expand / collapse plus / minus brush.
ExpanderGlyph
Gets or sets the shape the expand / collapse control is drawn as.
ExpandButtonImage and CollapseButtonImage still cover the drawn glyph when either is set. The colours come from ExpandCollapseControlFillBrush, ExpandCollapseBorderBrush and ExpandCollapsePlusMinusBrush whichever shape is chosen.InactiveSelectionBackgroundBrush
Gets or sets the background of a selected row while the control does not have focus.
Value. The inactive selection brush. Defaults to the system's control colour.
SelectionBackgroundBrush applies only while the tree has focus; set this as well to keep a designed selection colour when the user clicks elsewhere.InactiveSelectionForegroundBrush
Gets or sets the text colour of a selected row while the control does not have focus.
Value. The inactive selection text brush. Defaults to the system's control text colour.
IsMultiSelectionEnabled
Gets or sets whether multi-selection of notes is enabled.
IsShiftMultiSelectionEnabled to True.IsNodesConnectingLineDotted
Gets or sets a value indicating whether the lines that join the nodes are drawn as dashes rather than solid.
IsNodesConnectingLineVisible
Gets or sets a value indicating whether the control should draw the nodes connecting line.
IsShiftMultiSelectionEnabled
Gets or sets whether the SHIFT + selection is enabled for multi-selection of nodes. By default this value is false.
MouseOverBackgroundBrush
Gets or sets the row background drawn while the pointer is over it.
Value. The hover brush. Null by default, which draws no hover at all.
MouseOverForegroundBrush
Gets or sets the row foreground drawn while the pointer is over it.
Value. The hover text brush. Null by default, leaving the text as it is.
MultiSelectedItems
Gets the multi-selected items.
Value. The multi selected items.
NodesConnectingLineBrush
Gets or sets the nodes connecting line brush.
Value. The nodes connecting line brush.
RenderCollapseExpandVisualAlwaysInTheFirstColumn
Gets or sets a value indicating whether to always render the first column as the tree-list view colum.
RowBackgroundBrush
Gets or sets the background given to the rows in even positions on screen.
AlternateRowBackgroundBrush is null .RowSeparatorBrush
Gets or sets the brush the line under each row is drawn in. No line is drawn while this is null , which is what it starts as.
SelectionBackgroundBrush
Gets or sets the node/row item "selection" background brush.
SelectionForegroundBrush
Gets or sets the node/row item "selection" foreground brush.
SortDirection
Gets which way round SortedColumn is sorted.
SortGlyphBrush
Gets or sets the colour the sort arrow over the column heading is drawn in.
SortedColumn
Gets the column the rows are currently in order of, or null when they are in the order they were added.
Theme
Gets or sets the built-in colour scheme the control draws itself in.
Custom clears the brushes a scheme writes, so the control goes back to its default colours - which are the skin's, when Binarymission.WPF.Skinning.BinarySkinManager has one in force.TreeListViewColumn
Gets or sets the column that carries the tree - the expander, the indent and the connecting lines. Every other column draws as a plain cell, and the nodes keep their parents and children whichever column this is.
Value. The tree list view column.
TreeListViewColumnIndex follows it - including when the user drags that column to a new position. RenderCollapseExpandVisualAlwaysInTheFirstColumn overrides both.TreeListViewColumnIndex
Gets or sets the position of the column that carries the tree.
Value. The index of the tree column, or -1 when none has been asked for.
TreeListViewItemIsRenderedWithRoundedCorner
Gets or sets a value indicating whether the tree list view item is rendered with rounded corner.
Methods
ClearColumnSort
Stops sorting by a column.
CollapseAllNodes
Collapses all nodes.
ExpandAllNodes
Expands all nodes.
- shouldScrollBackToTop
- if set to true the control should scroll back to the top item in the tree-listview instance.
ExpandNodeByIndex
Expands the index of the node by.
- index
- The index.
ExpandNodesByIndices
Expands the nodes by indices.
- indices
- The indices.
GetContainerForItemOverride
Creates the container that one item is shown in, which for this control is a BinaryTreeListViewItem.
GetSortMemberPath
Gets the property a column is sorted by.
- column
- The column.
Returns. The property's name, or null .
IsItemItsOwnContainerOverride
Reports whether an item can be shown as it stands, without being wrapped in a container of its own.
OnApplyTemplate
Applies the control's template.
OnItemsChanged
Raises the ItemsChanged event. BinaryTreeListView overrides it so the control's own handling runs alongside the base behavior.
- e
- The data for the event.
RefreshRowDecorations
Draws every row on screen again.
RefreshRowStriping
Lays the alternating row backgrounds again, in the order the rows are drawn.
SelectNodeByIndex
Selects the index of the node by.
- index
- The index.
SelectNodesByIndices
Selects several nodes at once by their positions in the list.
- indices
- The zero-based positions to select. An empty sequence selects nothing.
SetSortMemberPath
Sets the property a column is sorted by.
- column
- The column.
- path
- The property's name.
SortByColumn
Puts every branch of the tree in order of one column.
- column
- The column to sort by.
- direction
- Which way round to sort it.
DisplayMemberBinding nor a SortMemberPath : there is then no property to read, and a column of templated cells cannot be guessed at.Events
ColumnReordered
Occurs after a column has been moved by dragging its heading.
ColumnSorted
Occurs after the rows have been put in order of a column.
Fields
AllowsColumnReorderProperty
Identifies the AllowsColumnReorder dependency property.
AllowsColumnSortingProperty
Identifies the AllowsColumnSorting dependency property.
AlternateRowBackgroundBrushProperty
Identifies the AlternateRowBackgroundBrush dependency property.
CollapseButtonImageProperty
Identifies the CollapseButtonImage dependency property.
ColumnHeaderBackgroundBrushProperty
Identifies the ColumnHeaderBackgroundBrush dependency property.
ColumnHeaderBorderBrushProperty
Identifies the ColumnHeaderBorderBrush dependency property.
ColumnHeaderForegroundBrushProperty
Identifies the ColumnHeaderForegroundBrush dependency property.
ColumnHeaderHeightProperty
Identifies the ColumnHeaderHeight dependency property.
ColumnHeaderHoverBackgroundBrushProperty
Identifies the ColumnHeaderHoverBackgroundBrush dependency property.
ColumnHeaderPressedBackgroundBrushProperty
Identifies the ColumnHeaderPressedBackgroundBrush dependency property.
ColumnReorderIndicatorBrushProperty
Identifies the ColumnReorderIndicatorBrush dependency property.
ExpandButtonImageProperty
Identifies the ExpandButtonImage dependency property.
ExpandCollapseBorderBrushProperty
Identifies the ExpandCollapseBorderBrush dependency property.
ExpandCollapseButtonImageStretchProperty
Identifies the ExpandCollapseButtonImageStretch dependency property.
ExpandCollapseControlFillBrushProperty
Identifies the ExpandCollapseControlFillBrush dependency property.
ExpandCollapsePlusMinusBrushProperty
Identifies the ExpandCollapsePlusMinusBrush dependency property.
ExpanderGlyphProperty
Identifies the ExpanderGlyph dependency property.
InactiveSelectionBackgroundBrushProperty
Identifies the InactiveSelectionBackgroundBrush dependency property.
InactiveSelectionForegroundBrushProperty
Identifies the InactiveSelectionForegroundBrush dependency property.
IsMultiSelectionEnabledProperty
Identifies the IsMultiSelectionEnabled dependency property.
IsNodesConnectingLineDottedProperty
Identifies the IsNodesConnectingLineDotted dependency property.
IsNodesConnectingLineVisibleProperty
Identifies the IsNodesConnectingLineVisible dependency property.
IsShiftMultiSelectionEnabledProperty
Identifies the IsShiftMultiSelectionEnabled dependency property.
MouseOverBackgroundBrushProperty
Identifies the MouseOverBackgroundBrush dependency property.
MouseOverForegroundBrushProperty
Identifies the MouseOverForegroundBrush dependency property.
NodesConnectingLineBrushProperty
Identifies the NodesConnectingLineBrush dependency property.
RenderCollapseExpandVisualAlwaysInTheFirstColumnProperty
Identifies the RenderCollapseExpandVisualAlwaysInTheFirstColumn dependency property.
RowBackgroundBrushProperty
Identifies the RowBackgroundBrush dependency property.
RowSeparatorBrushProperty
Identifies the RowSeparatorBrush dependency property.
SelectionBackgroundBrushProperty
Identifies the SelectionBackgroundBrush dependency property.
SelectionForegroundBrushProperty
Identifies the SelectionForegroundBrush dependency property.
SortDirectionProperty
Identifies the SortDirection dependency property.
SortGlyphBrushProperty
Identifies the SortGlyphBrush dependency property.
SortMemberPathProperty
Identifies the SortMemberPath attached property, which names the property to sort a column by when the column draws its cells with a template and so has no DisplayMemberBinding to read one from.
SortedColumnProperty
Identifies the SortedColumn dependency property.
ThemeProperty
Identifies the Theme dependency property.
TreeListViewColumnIndexProperty
Identifies the TreeListViewColumnIndex dependency property.
TreeListViewColumnProperty
Identifies the TreeListViewColumn dependency property.
TreeListViewItemIsRenderedWithRoundedCornerProperty
Identifies the TreeListViewItemIsRenderedWithRoundedCorner dependency property.