给一个Togglebutton这个颜色“#FF5D0000”在MainWindow [英] Give a Togglebutton this Color "#FF5D0000" in the MainWindow

查看:65
本文介绍了给一个Togglebutton这个颜色“#FF5D0000”在MainWindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Hello Folks
Hello Folks

推荐答案

Sealed类Brushes包含预定义的SolidColorBrush对象你可以选择。但是没有一个名为Owncolor的对象。 Owncolor是您创建的变量,已使用您的自定义SolidColorBrush"#FF5D0000"进行初始化。您只需将
分配给按钮的Foreground属性,如下所示:

The Sealed class Brushes contains pre-defined SolidColorBrush objects you can choose from. But there is not an object named Owncolor. Owncolor is a variable you created that is already initialized with your custom SolidColorBrush "#FF5D0000". You simply assign it to the Foreground property of your button as follows:

SolidColorBrush Owncolor = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF5D0000"));
ToggleButton.Foreground = Owncolor;

或更简洁

ToggleButton.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF5D0000"));

其中'ToggleButton'有希望是你的ToggleButton的XAML名称?!选择与类名不同的名称可能更好,例如。 'toggleButton'。

where 'ToggleButton' hopefully is the XAML name of your ToggleButton?! It might be better to choose a name different from the class name, eg. 'toggleButton'.

wizend


这篇关于给一个Togglebutton这个颜色“#FF5D0000”在MainWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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