如何将 LinearGradientBrush 值转换为字符串值或颜色值。?我有一个返回 LinearGradientBrush 值的方法
private LinearGradientBrush SetBackground(string color1, string color2)
{
LinearGradientBrush brush = new LinearGradientBrush();
brush.StartPoint = new Point(0, 0);
brush.EndPoint = new Point(0, 1);
GradientStop gra1 = new GradientStop();
gra1.Color = (Color)ColorConverter.ConvertFromString(color1);
gra1.Offset = 1;
GradientStop gra2 = new GradientStop();
gra2.Color = (Color)ColorConverter.ConvertFromString(color2);
gra2.Offset = 0;
brush.GradientStops.Add(gra1);
brush.GradientStops.Add(gra2);
return brush;
}
我需要把这个返回值转换成字符串类型或者十六进制值比如“FFFF00”表示,是否可以,如果可以,怎么做?提前致谢