简体   繁体   English

如何从RGB或十六进制设置画笔

[英]How to set Brush from RGB or hex

Hey I want to set color of BorderBrush in .xaml.cs file and don't want to use colours like Red or Green and want to use whole palette from HEX or RGB. 嘿,我想在.xaml.cs文件中设置BorderBrush的颜色,并且不想使用红色或绿色之类的颜色,并且不想使用十六进制或RGB的整个调色板。 I don't know how to covert it. 我不知道如何隐秘。 Maybe you know how to solve this problem. 也许您知道如何解决此问题。

    private void TxbName_MouseEnter(object sender, MouseEventArgs e)
    {
        txbName.BorderBrush = Brushes.Green;
        txblImie.Foreground = Brushes.Red;
    }

You can use the ConvertFrom method from BrushConverter . 您可以使用BrushConverterConvertFrom方法。

var converter=new BrushConverter();
txblImie.Foreground = (Brush)converter.ConvertFrom("#ff0000");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM