New to Telerik UI for WPF? Download free 30-day trial

Expand and Collapse Items

To expand an item click on the expander icon. To expand an item programmatically set the IsExpanded property to True. To collapse an item set the IsExpanded property to False. When the item is expanded/collapsed it fires the PreviewExpand, Expanded and PreviewCollapsed, Collapsed events respectively. These events are available for the RadTreeView and RadTreeViewItem classes.

When you need to expand or collapse all the items recursively for a given item use the ExpandAll() and CollapseAll() methods of the RadTreeViewItem respectively. When you need to expand/collapse all the nodes in the tree use ExpandAll() and CollapseAll() methods of the RadTreeView.

If the RadTreeView is bound, the expand methods can only be called after the tree has loaded.

When you need to have only a single branch of the tree expanded, set the IsSingleExpandPath property of the RadTreeView to True. Setting this property to True will automatically collapse the already expanded branch if a new branch is going to be expanded.

The RadTreeView API offers you the ability to expand an item by path programmatically. In order to do this you should use the ExpandItemByPath() method of the RadTreeView.

Using the ExpandItemByPath() method of the RadTreeView class is a potentially expensive operation if the item is not visible. The method will recursively expand and scroll items into view, updating the layout numerous times. Almost certainly the method should not be called in a loop (multiple times). If you need to do so, there is probably a better way to achieve what you need.

For more information read the topic about Expanding and Collapsing Items.

See Also

In this article