WPF 分隔符位置
我正在使用分隔符在边框内绘制一条垂直线。起初这没问题,因为线条需要居中,但现在我需要将其定位在距左边框的自定义 x 位置。有办法做到这一点吗?
<Border x:Name="border" ClipToBounds="True" Background="White" BorderBrush="Black" BorderThickness="2">
<Separator BorderBrush="Black" BorderThickness="2">
<Separator.LayoutTransform>
<RotateTransform Angle="90" />
</Separator.LayoutTransform>
</Separator>
</Border>
I'm using a Separator to draw a vertical line inside a Border. At first this was ok because the line needed to be centered, but now I need to position it at a custom x-position from the left border. Is there a way to do that?
<Border x:Name="border" ClipToBounds="True" Background="White" BorderBrush="Black" BorderThickness="2">
<Separator BorderBrush="Black" BorderThickness="2">
<Separator.LayoutTransform>
<RotateTransform Angle="90" />
</Separator.LayoutTransform>
</Separator>
</Border>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定正确的方法(如果可用),但如果您不调整边框大小,则可以使用如下边距:
I'm not sure of the proper way, if availble, but if you are not resizing the border, you could use a margin like this:
您可以进行的最简单的更改就是设置 HorizontalAlignment,然后使用边距来偏移分隔符(默认值为 0,2,0,2):
如果您有其他方法,还有很多其他方法可以实现相同的视觉效果要求。
The simplest change you can make is just to set the HorizontalAlignment and then use Margins to offset the Separator (the default is 0,2,0,2):
There are lots of other ways you could achieve the same visual effect if you have other requirements.