I have a strange WPF/XAML problem. By default, I want all of the nodes in this TreeView to be expanded. Eventually I'll bind it to my view model, but right now I just want them all expanded by default.
This is the part of the code in question (that I am currently using)
<HierarchicalDataTemplate DataType="{x:Type Model:DirectoryItem}"
ItemsSource="{Binding Items}">
<TextBlock Text="{Binding Path=Name}"
ToolTip="{Binding Path=Path}" />
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type Model:FileItem}">
<TextBlock Text="{Binding Path=Name}"
ToolTip="{Binding Path=Path}" />
</DataTemplate>
In particular, the part where I have the setter property as IsExpanded.
As you can see by the images below, this code is sort-of working. If I expand the root nodes, then everything is expanded by default.
But why are the root nodes not expanded by default as well? I have no idea why it is doing this.