1
有大量關於如何設置TextBlock元素的Foreground屬性的文檔。然而,我不能找到任何方法從TextBlock的Foreground屬性中獲取十六進制代碼作爲字符串(例如黑色的「#FF000000」)。從TextBlock的Foreground屬性獲取十六進制代碼
我正在使用Windows Phone 8/Silverlight。
有大量關於如何設置TextBlock元素的Foreground屬性的文檔。然而,我不能找到任何方法從TextBlock的Foreground屬性中獲取十六進制代碼作爲字符串(例如黑色的「#FF000000」)。從TextBlock的Foreground屬性獲取十六進制代碼
我正在使用Windows Phone 8/Silverlight。
前提是Foreground
屬性設置爲一個的SolidColorBrush,你可以只調用
var colorString = ((SolidColorBrush)textBlock.Foreground).Color.ToString();
謝謝!我一直在努力使用GetValue(Foreground)以及其他各種解決方法。 –