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

How to use hex colour for SolidColorBrush with Windows Phone

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

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

您可以调用 Color.FromArgb method 并指定颜色的各个红色、绿色和蓝色分量:

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