views:

1900

answers:

2

How can I expand all TreeView nodes in WPF? In WinForms there was a ExpandAll() method which does this.

A: 

The WPF TreeView class does not have an ExpandAll method. Thus you'd have to loop through the nodes and set their IsExpanded properties to true.

M. Jahedbozorgan
+11  A: 

See these blog entires by Bea Stollnitz

How can I expand items in a TreeView? - Part I

Basically you can do it by adding an implicit sytle,

<Page.Resources>
    <collections:ArrayList x:Key="treeOfLife">
        <local:Domain Classification="Bacteria">
            <local:Kingdom Classification="Eubacteria" />
        </local:Domain>
        …
    </collections:ArrayList>
    …
    <Style TargetType="TreeViewItem">
        <Setter Property="IsExpanded" Value="True" />
    </Style>
</Page.Resources>
Binary Worrier
+1 for sparing me the effort of looking up that URL in my bookmarks :)
David Schmitt
The approaches towards a WinForms and WPF TreeView are very different. If you're going to spend sometime with WPF TreeViews, read some of the stuff written by Josh Smith http://joshsmithonwpf.wordpress.com/2008/05/24/the-wpf-treeview-is-a-view-of-a-tree/
Gishu