You are missing a key bit in your HierarchicalDataTemplate
- how to render the subelements:
<HierarchicalDataTemplate x:Key="BinderTemplate"
ItemsSource="{Binding Path=SubSections}"
DataType="{x:Type local:SubSectionViewModel}">
<StackPanel>
<Expander Header="{Binding SubSection.SubSectionName}">
<ItemsControl Margin="5,0,0,0"
ItemsSource="{Binding SubSections}"
ItemTemplate="{DynamicResource BinderTemplate}"/>
</Expander>
</StackPanel>
</HierarchicalDataTemplate>
EDIT: Not to steal @BDE's thunder, but he/she's mostly correct about the use of DataType
- but this is the way you'd "simplify" the above XAML:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<!-- normal template for sections -->
<DataTemplate DataType="{x:Type local:SectionViewModel}">
<GroupBox Header="{Binding Section.SectionName}">
<ItemsControl ItemsSource="{Binding SubSections}"/>
</GroupBox>
</DataTemplate>
<!-- hierarchical template for subsections -->
<HierarchicalDataTemplate
DataType="{x:Type local:SubSectionViewModel}">
<StackPanel>
<Expander Header="{Binding SubSection.SubSectionName}">
<ItemsControl Margin="5,0,0,0"
ItemsSource="{Binding SubSections}"/>
</Expander>
</StackPanel>
</HierarchicalDataTemplate>
</Window.Resources>
<Grid>
<!--
no need to specify ItemTemplate if WPF can suss out all the item types
-->
<ItemsControl Name="lstMain" ItemsSource="{Binding Sections}"/>
</Grid>
</Window>