如何更改 WPF `` 的颜色?
我在表单中使用
但不知道如何更改其颜色。 Border
/Foreground
/Background
都不存在。请帮忙。
I use <Separator />
in my form but don't know how to change its color. None of Border
/Foreground
/Background
does exist. Plese help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以设置背景:
You can set the Background:
嗯...我认为
Separator
是少数无法使用简单样式的元素之一。根据MSDN文档,您需要指定SeparatorStyleKey
。例如,对于
ToolBar
您可以这样做:Hmm... I think the
Separator
is one of the few elements that will not work using a simple style. Based on the MSDN documentation, you need to specify theSeparatorStyleKey
.For instance for a
ToolBar
you would do this:使用样式
分隔符只是一个边框元素,现在您可以按照自己喜欢的方式更改其外观?
Use styles
A seperator is just a border element and now you can change its appearance any way you like?
您可以使用以下代码设置
Separator
的颜色:请注意
BorderThickness< /code> 属性也必须应用。
you can set the
Separator
's color using this code:<Separator BorderBrush="Red" BorderThickness="1"/>
NOTE that the
BorderThickness
property must be applied too.或者,您可以选择使用矩形元素:
修改/形状更容易一些。
Alternatively you could choose to use a Rectangle element:
<Rectangle HorizontalAlignment="Stretch" Fill="Blue" Height="2"/>
It's somewhat easier to modify/shape.