Any way to make the Separator in the WPF menu narrower?

I noticed that the default margin or height of the separator, since it is styled on the menu in WPF, seems a little larger than some other applications, such as Visual Studio 2010. I know that these separators can be changed by templates using a new style using a special ControlTemplate, but, as always, I'm looking for any possible way to change this without having to manually override the composition of the control.

If what I ask is not possible, I will accept the answer if someone can give an authoritative and comprehensive explanation. I would also like to emphasize that I am not interested in a lecture on how to redefine ControlTemplate, since I consider this as a last resort and I already know how to do it.

+7
wpf separator menu
source share
2 answers

The style for aero.normalcolor MenuItem Separator is as follows:

<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Separator}"> <Grid SnapsToDevicePixels="true" Margin="0,6,0,4"> <Rectangle Height="1" Margin="30,0,1,1" Fill="#E0E0E0"/> <Rectangle Height="1" Margin="30,1,1,0" Fill="White"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> 

You will need to copy this style into your app.xaml and change Margin="0,6,0,4" to your preference.

+12
source share

I always use a negative margin: <Separator Margin="0,-4" /> .

+1
source share

All Articles