Hello, I have a 4-level TreeView that is bound to custom classes that have generic base collections.
In order to display the data, I am using the following hierarchical data template:
I am setting the tree view's ItemsSource (Level1) in the code-behind class.
Now this works fine and the data is being displayed correctly. However, I don't want to display level 3 items unless they have children (the level 4 collection has items). Is it possible to do that using xaml (i.e. modifying the above piece of code)?
In order to display the data, I am using the following hierarchical data template:
<HierarchicalDataTemplate ItemsSource="{Binding Level2}">
<TextBlock Tag="lvl1" Text="{Binding Name}" />
<HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Level3}">
<TextBlock Tag="lvl2" Text="{Binding Name}"></TextBlock>
<HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Level4}">
<TextBlock Tag="lvl3" Text="{Binding Name}"></TextBlock>
<HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate>
<TextBlock Tag="lvl4" Text="{Binding Name}"></TextBlock>
</HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
I am setting the tree view's ItemsSource (Level1) in the code-behind class.
Now this works fine and the data is being displayed correctly. However, I don't want to display level 3 items unless they have children (the level 4 collection has items). Is it possible to do that using xaml (i.e. modifying the above piece of code)?