I have something like this in my XAML:
<TreeView DataContext="{Binding Source={StaticResource Locator}}" ItemsSource="{Binding SomeTree.TopLevelItems}">
<TreeView.Resources>
<DataTemplate DataType="{x:Type vm:ILeaf}">
<CheckBox Content="{Binding Name}" IsThreeState="False" IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
<HierarchicalDataTemplate DataType="{x:Type vm:IGroup}" ItemsSource="{Binding Children}">
<CheckBox Content="{Binding Name}" IsThreeState="True" IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
vm: is defined accordingly:
xmlns:vm="clr-namespace:My.ViewModels.MyTree"
And the MyTree namespace contains the interfacesIGroup and ILeaf.
The SomeTree.TopLevelItems is an enumerable of IGroups and ILeafs (it is populated dynamically).
Now, my TreeView should display a tree of checkboxes accordingly, but it is only displaying the top-level elements of the items source, is NOT applying the data template, and calls ToString() on the elements instead.
The other post which mentions the same problem does not apply here, I already checked that.
What am I missing / doing wrong?