在WPF中将borderbrush设置为LinearGradientBrush
我是 WPF 新手,仍然遇到一些基本问题。
我有一个来自 devcomponents 的控件,默认为蓝色边框。我的文本框等有更灰色的颜色。我希望 devcomponents 控件具有相同的边框。
我查看 TextBox 的属性,发现 BorderBrush 设置为“System.Windows.Media.LinearGradientBrush”,但我无法放置 -
<WpfEditors:IntegerInput BorderBrush="System.Windows.Media.LinearGradientBrush"...
事实上,我无法放置 -
<TextBox BorderBrush="System.Windows.Media.LinearGradientBrush" ...
我错过了什么魔力?
谢谢。
I'm new to WPF and still having some basic problems.
I have a control from devcomponents that defaults to a blue border. My textboxes etc. have a more grey colour. I want the devcomponents control to have the same border.
I look in the properties of a TextBox and see that BorderBrush is set to "System.Windows.Media.LinearGradientBrush" yet I can't put -
<WpfEditors:IntegerInput BorderBrush="System.Windows.Media.LinearGradientBrush"...
In fact, I can't put -
<TextBox BorderBrush="System.Windows.Media.LinearGradientBrush" ...
What magic am I missing?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须为属性
BorderBrush
分配一个 Brush(正如您可以通过其名称猜到的那样)。Brush
的一种是LinearGradientBrush
(在颜色之间产生渐变的东西)SolidColorBrush
是另一种也可以被分配的画笔。看起来您使用的这种控件已经分配了一个
LinearGradientBrush
。现在您可以分配您选择的画笔并覆盖已设置的画笔。
LinearGradientBrush
示例:如果您希望边框仅采用纯色,您也可以使用
SolidColorBrush
。或者只使用现有的转换器颜色 -->
SolidColorBrush
编辑:
如果您希望所有控件都具有相同的边框,您可以将 Brush 添加到容器对象的
ResourceDictionary
中,并将其重用于所有控件。 。To the property
BorderBrush
you have to assign a Brush (as you could guess by its name).One kind of
Brush
is aLinearGradientBrush
(the thing which makes a gradient between colors)SolidColorBrush
is another kind of Brush which could also get assigned.As it looks as this kind of control you use has already assigned a
LinearGradientBrush
.Now you can assign a Brush of your choice and override the already set
Brush
.Example for a
LinearGradientBrush
:If you want your border just in a a solid color you can also use a
SolidColorBrush
.or just use the existing Converter Color -->
SolidColorBrush
EDIT:
And if you want that all your controls have the same Border you can add a Brush to the
ResourceDictionary
of a container object and reuse it for all the controls...