I have a MenuItem that dynamically creates submenu items from ItemsSource -property.
For grouping, I have separators in the menu. A separator is created for each null entry in the ItemsSource collection using the MenuItem.ItemContainerStyle checklist.
This works great, but the separator is not as optical as the other separators that fit into the Items collection on the menu.
Is there a way to change the appearance of the separator so that it looks equal to the "normal" separators of the menu items?
Here is the code I'm using:
<MenuItem.ItemContainerStyle> <Style TargetType="MenuItem"> <Setter Property="Header" Value="{Binding Title}"/> <Setter Property="Command" Value="{Binding Command}"/> <Style.Triggers> <DataTrigger Binding="{Binding }" Value="{x:Null}"> <Setter Property="Template" > <Setter.Value> <ControlTemplate> <Separator /> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style> </MenuItem.ItemContainerStyle>
wpf mvvm
HCL
source share