I use the wpf in a list menuitems in a normal menu (not the context menu).
Using the following style, the separator is not drawn:
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
    <Setter Property="Height" Value="2" />
</Style>
The value of Height must at least be 12, but then the distance from menuitems is too large.
What is happening here? Is it logical? Is there a solution?
Simply scale the separator on the Y axis
 <Separator>
    <Separator.RenderTransform>
        <ScaleTransform ScaleY="3" />
     </Separator.RenderTransform>
 </Separator>
This will set the separator's height to 3 times the original one.
see this: How to: Scale an Element
You can use the Margin property to size and/or space the Separator element to a degree:
<StackPanel>
    <Button Width="100" Content="Click me" />
    <Separator Margin="50,20" />
    <Button Width="100" Content="Click me too" />
</StackPanel>
In general, its length will fill the available area, while its width will remain at one pixel, or vice versa depending on its orientation. This will affect its Width:
<StackPanel>
    <Button Width="100" Content="Click me" />
    <Separator Margin="20" Width="20" />
    <Button Width="100" Content="Click me too" />
</StackPanel>
This won't affect the Height of the line in this orientation, but it will affect the total space that it takes:
<StackPanel>
    <Button Width="100" Content="Click me" />
    <Separator Margin="20" Height="50" />
    <Button Width="100" Content="Click me too" />
</StackPanel>
If you want more control over the line, then I would recommend that you use the Line Class instead.
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