WPF边框厚度增加方向
嘿。另一个 WPF 问题。在我的 XAML 代码中,我有一个边框:
<Border x:Name="myBorder" Background="AliceBlue"
Width="200" Height="200"
BorderThickness="10" BorderBrush="Black">
</Border>
在代码中的某处,我增加了 BorderThickness
double thickness = myBorder.BorderThickness.Bottom + 2;
myBorder.BorderThickness = new Thickness(thickness);
,结果是边框的权重增加,但不是在 200x200 宽度-高度之外,而是在内部,从而减小了尺寸。有没有办法做到相反?
Hey. Another WPF question. In my XAML code I have a border:
<Border x:Name="myBorder" Background="AliceBlue"
Width="200" Height="200"
BorderThickness="10" BorderBrush="Black">
</Border>
and somewhere in code I increase the BorderThickness
double thickness = myBorder.BorderThickness.Bottom + 2;
myBorder.BorderThickness = new Thickness(thickness);
and the result is that the border's weight increases but not outside the 200x200 width-height, but inner, decreasing the dimension. Is there a way to do the opposite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,实际上您应该在边框的内部或外部控件上设置宽度和高度,而不是在边框本身上。然后可以为边框设置负边距,等于减去边框厚度的值。像这样的事情应该达到目的:
Well, actually you should set the width and height on the inner or outer control of the border, not on the border itself. Then you can set a negative margin for the border, equal to minus the value of the border thickness. Something like this should to the trick:
看来您需要相应地增加宽度和高度。
It looks like you need to increase Width and Height accordingly.