Is there a way to automatically expand all nodes from a treeview in WPF? I searched and didn\'t even find an expand function in the treeview property.
Thanks
Carlo's answer was better because it opens all levels
This improves upon that example with a little more concise code example.
private void ExpandAllNodes(TreeViewItem treeItem)
{
treeItem.IsExpanded = true;
foreach (var childItem in treeItem.Items.OfType())
{
ExpandAllNodes(childItem);
}
}
Call it by using this line of code
TreeViewInstance.Items.OfType().ToList().ForEach(ExpandAllNodes);