Search code examples
c#wpftreeviewexpand

How to expand all nodes of a WPF treeview in code behind?


I might be suffering of Monday's dumbness, but I can't find a nice way of expanding all treeview nodes after I've added them in code behind (something like treeView.ExpandAll()).

Any quick help?


Solution

  • In xaml you could do it as follows :

     <TreeView.ItemContainerStyle>
                <Style TargetType="TreeViewItem">
                    <Setter Property="TreeViewItem.IsExpanded" Value="True"/>
                </Style>
     </TreeView.ItemContainerStyle>