I am working on a WPF project and I have a TreeView
using HierarchicalDataTemplates
. I have been able to establish some different levels of nodes. Everything is going well so far.
<TreeView Margin="14,14,14,14" Name="treeView" ItemsSource="{Binding Tree}"
BorderThickness="0">
<TreeView.Resources>
<!--
First Level
-->
<HierarchicalDataTemplate DataType="{x:Type vm:FirstLevelViewModel}"
ItemsSource="{Binding Children}" >
<StackPanel Orientation="Horizontal" >
<TextBlock Text="{Binding SomeText}" FontSize="14" FontWeight="Bold" Foreground="DarkBlue" />
</StackPanel>
</HierarchicalDataTemplate>
<!--
Second Level
-->
<HierarchicalDataTemplate DataType="{x:Type vm:SecondLevelViewModel}"
ItemsSource="{Binding Children}" >
<CheckBox Name="checkBox" IsChecked="{Binding IsChecked}" IsEnabled="{Binding IsEnabled}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SomeText}" FontSize="14" />
</StackPanel>
</CheckBox>
</HierarchicalDataTemplate>
. . . .
My problem is that: I need some nodes to be non collapsible.
Is there any way to achieve that? I have been searching about it with no luck.