Search
Collapsing and Expanding Tree Branches

If a diagram represents a tree structure, the tree branch starting from a node can be collapsed or expanded again in order to hide or display hierarchy details. To enable this, set the Expandable property. To get or set whether a tree branch is expanded or collapsed, use the Expanded property of its root node.

Displaying Expand/Collapse Button

If the Expandable property of a node is set to true, there is a [±] button displayed beside the node to allow users to collapse or expand the tree branch starting there. The button location can be customized through the diagram's ExpandButtonPosition property, and its color change through ExpandButtonBrush. By default, pressing that button automatically toggles the Expanded property of the node and raises the TreeExpanded or TreeCollapsed events.

Defining Tree Direction

A node can be connected to other nodes through outgoing and incoming links. Setting the ExpandOnIncoming property specifies which items connected to a node will be regarded as its descendants. If ExpandOnIncoming is false (default value) then each node will be regarded as a parent of its outgoing links and the items attached to them. If ExpandOnIncoming is set to true, the node's incoming links define its children. So that property specifies the direction of parent-children relationship between diagram items and respectively the overall direction in which collapsing / expanding is done.

Expanding a Branch Recursively

Use the RecursiveExpand property to specify whether the whole tree branch starting from a node will be shown when expanding, or only the first level of descendants.

Custom Expand/Collapse Functionality

The ExpandButtonAction property lets you override the standard functionality of the [±] button. Set this property to RaiseEvents and handle the ExpandButtonClicked event if you need to implement your own expand/collapse logic.