ExpandSubtree Method

TreeViewItem.ExpandSubtree Method ()

.NET Framework 4.6 and 4.5

Expands the TreeViewItem control and all its child TreeViewItem elements.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public void ExpandSubtree()

The following examples show how to find the selected TreeViewItem and expand it and all of it child items. The following XAML creates a TreeView and populates it with some data.

The following code traverses the TreeView to find the selected TreeViewItem and then calls ExpandSubtree to display all child items of the selected TreeViewItem.


The GetTreeViewItem method only works for TreeViewItem controls that are not virtualized. To learn how to find a TreeViewItem that may be virtualized, see How to: Find a TreeViewItem in a TreeView.

.NET Framework
Available since 4.0
Return to top
© 2015 Microsoft