I have a multi-level WPF TreeView that uses HierachicalDataTemplate
to bind to my view model. I want to see how the tree will look fully expanded at design time, but since the designer doesn't allow you to click on the nodes, I have been trying to find a design-time only solution using mc:Ignorable="d"
and ItemContainerStyle
.
I have kind of been able to do this as shown below. By itself the TreeView.ItemContainerStyle
section does exactly as I would like it to, but when I add a d:
, suddenly the designer acts like the style isn't there and collapses all the tree nodes. The designer doesn't show any errors or warnings.
<TreeView ItemsSource="{Binding ParentCollection}">
<d:TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</d:TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildItems}">
<!-- And so on -->
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
Is there a good way for me to view my tree nodes expanded at design time, but have them start as collapsed at runtime?