1
Theres a problem。每使用C#-Code一個字符串值,我不能設置BorderBrush(不XAML):如何從字符串中設置Border.BorderBrush
((Border)((Image)sender).Parent).BorderBrush = "#FFBCC7D8";
如何解決這個問題呢?
Theres a problem。每使用C#-Code一個字符串值,我不能設置BorderBrush(不XAML):如何從字符串中設置Border.BorderBrush
((Border)((Image)sender).Parent).BorderBrush = "#FFBCC7D8";
如何解決這個問題呢?
您必須使用Converter將字符串轉換爲畫筆對象。在框架中有一個BrushConverter來做到這一點。
BrushConverter converter = new BrushConverter();
BorderBrush brush = converter.ConvertFromString("#FFBCC7D8") as Brush;
((Border)((Image)sender).Parent).BorderBrush = brush;