String轉換成Color
string-"ffffff"
Color color = (Color)ColorConverter.ConvertFromString(string);
String轉換成Brush
BrushConverter brushConverter = new BrushConverter(); Brush brush = (Brush)brushConverter.ConvertFromString(string);
Color轉換成Brush
Brush brush = new SolidColorBrush(color));
Brush轉換成Color
//先將Brush轉成string,再轉成Color Color color= (Color)ColorConverter.ConvertFromString(brush.ToString()); //將Brush轉成SolidColorBrush,再取Color Color color= ((SolidColorBrush)CadColor.Background).Color;
(ARGB)轉換為Brush
Brush br = new SolidColorBrush(Color.FromArgb(cl.Color.A, cl.Color.R, cl.Color.G, cl.Color.B));