我在普通菜单(而不是上下文菜单)的列表菜单项目中使用wpf。
使用下列样式,不绘制分隔符:
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
<Setter Property="Height" Value="2" />
</Style>
高度的值至少必须是12,但是离菜单的距离太大了。
这里发生了什么事?这合乎逻辑吗?有解决办法吗?
发布于 2018-08-14 10:42:40
只需缩放Y轴上的分隔符
<Separator>
<Separator.RenderTransform>
<ScaleTransform ScaleY="3" />
</Separator.RenderTransform>
</Separator>
这将把分离器的高度设置为原来的3倍。
参见:如何:缩放元素
发布于 2013-10-08 10:09:01
您可以使用Margin
属性在一定程度上调整Separator
元素的大小和/或空间:
<StackPanel>
<Button Width="100" Content="Click me" />
<Separator Margin="50,20" />
<Button Width="100" Content="Click me too" />
</StackPanel>
一般来说,它的长度将填充可用区域,而宽度将保持在一个像素,反之亦然,取决于它的方向。这将影响其Width
。
<StackPanel>
<Button Width="100" Content="Click me" />
<Separator Margin="20" Width="20" />
<Button Width="100" Content="Click me too" />
</StackPanel>
这不会影响这条线在这个方向上的Height
,但它将影响它所占用的总空间:
<StackPanel>
<Button Width="100" Content="Click me" />
<Separator Margin="20" Height="50" />
<Button Width="100" Content="Click me too" />
</StackPanel>
如果您希望对行有更多的控制,那么我建议您改用班级。
发布于 2015-10-27 21:47:27
使用负差:
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
<Setter Property="Margin" Value="-4,0,-3,0" />
</Style>
https://stackoverflow.com/questions/19244379
复制相似问题