如何将颜色绑定到XAML-WPF中的画笔? [英] How to bind Color to a Brush in xaml - wpf?

查看:242
本文介绍了如何将颜色绑定到XAML-WPF中的画笔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一些彩色的按钮,我希望它们在鼠标悬停在其上方时具有发光效果.我在wpf4.make中通过阴影效果产生了辉光.我的问题是我希望阴影的颜色与按钮的属性之一(例如前景)绑定在一起.问题是我不能,因为颜色的类型是颜色,但前景的类型是画笔.有帮助吗?

P.S:因为它是按钮样式,所以我希望这种绑定可以在xaml中完成.

谢谢,如果有任何错误,对不起我的英语!

Hi
I have some colored buttons which i want them to have a glow effect whenever the mouse is over it. I have made the glow by drop shadow effect in wpf4.my problem is i want the color of the shadow to be bind with one of the properties of the button like Foreground. the problem is i cant because the type of the color is Color but the type of the Foreground is Brush. any helps?

P.S: because it''s in a button style i want this binding to be done in xaml.

thank you and sorry for my English if there is any mistakes!

推荐答案

您需要使用SolidColorBrush there.

请参阅 http://msdn.microsoft.com/zh-cn/library/system.windows.media.solidcolorbrush(v = VS.100).aspx [
You need to use a SolidColorBrush there.

See http://msdn.microsoft.com/en-us/library/system.windows.media.solidcolorbrush(v=VS.100).aspx[^]


这篇关于如何将颜色绑定到XAML-WPF中的画笔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆