I'm adding my hierarchical data to a Menu-Control using the HierarchicalDataTemplate.
<HierarchicalDataTemplate DataType="{x:Type local:MyType}" ItemsSource="{Binding Path=SubItems}">
<StackPanel>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
My Menu is created like this
<Menu>
<MenuItem ItemsSource="{Binding MyCollection}" Header="MainItem"></MenuItem>
</Menu>
How can a add a style to these generated MenuItems to set the IsCheckable
property for example. It's important that the main MenuItem (header named "MainItem" here) don't applies this style so it's not checkable.
I've tried several approaches using <Style>
and <DataTemplate
but with no success.