如何在Windows Phone中使用SolidColorBrush的十六进制颜色

时间:2016-07-24 18:09:50

标签: c# windows-phone textblock solidcolorbrush

我正在尝试以编程方式为文本块中的文本使用十六进制颜色(#E32017),但它不起作用。当涉及到Windows Phone的文本块时,是否有人知道如何使用十六进制颜色代替Colors.Red

TextBlock textBlock = new TextBlock();
textBlock.Inlines.Add(new Run { Text = "H", Foreground = new SolidColorBrush(Colors.Red) });

1 个答案:

答案 0 :(得分:2)

您可以拨打Color.FromArgb method并指定颜色的红色,绿色和蓝色组件:

Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xE3, 0x20, 0x17))