首页 > Windows开发 > 详细

c#-WPF string,color,brush之间的转换

时间:2018-09-20 10:22:14      阅读:360      评论:0      收藏:0      [点我收藏+]
原文:c#-WPF string,color,brush之间的转换

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)); 


c#-WPF string,color,brush之间的转换

原文:https://www.cnblogs.com/lonelyxmas/p/9678755.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!