I've noticed that the margin or height of the default Separator as it is styled in the menus in WPF seems to be slightly larger than some other applications such as Visual Studio 2010. I know that these Separators can be re-templated by applying a new style with a custom ControlTemplate but like always I'm looking for any possible way to change this without having to manually re-define the composition of the control.
If what I'm asking for isn't possible I will accept an answer if somebody can provide an authoritative and exhaustive explanation. Also I would like to stress that I'm not interested in a lecture about how to redefine the ControlTemplate as I'm treating that as the last resort and I'm already aware of how to accomplish this.
The style for the aero.normalcolor MenuItem Separator looks like this:
<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 would need to copy this style to your app.xaml and change the Margin="0,6,0,4"
to match your preferences.
I always use negative margin: <Separator Margin="0,-4" />
.
Edit 2022-03-15: Does not work anymore since Windows 10 came out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With