有很多关于如何设置TextBlock元素的Foreground属性的文档。但是,我无法找到任何方法将十六进制代码作为字符串(例如,黑色的“#FF000000”)从TextBlock的Foreground属性中获取。
我正在使用Windows Phone 8 / Silverlight。
答案 0 :(得分:4)
如果Foreground
属性设置为SolidColorBrush,则可以调用
var colorString = ((SolidColorBrush)textBlock.Foreground).Color.ToString();