1、String转换成Color

Color color = (Color)ColorConverter.ConvertFromString(string);

2、String转换成Brush

BrushConverter brushConverter = new BrushConverter();
            Brush brush = (Brush)brushConverter.ConvertFromString(string);

3、Color转换成Brush

Brush brush = new SolidColorBrush(color));

4、Brush转换成Color有两种方法:

(1)先将Brush转成string,再转成Color。

Color color= (Color)ColorConverter.ConvertFromString(brush.ToString());

(2)将Brush转成SolidColorBrush,再取Color。

Color color= ((SolidColorBrush)CadColor.Background).Color;

String、Brush、Color 相互转换的更多相关文章

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

    原文:c#-WPF string,color,brush之间的转换 String转换成Color string-"ffffff" Color color = (Color)Colo ...

  2. String与InputStream相互转换

    1.String to InputStream String str = "String与InputStream相互转换"; InputStream   in_nocode   = ...

  3. C#中String 与Color之间的相互转换

    C#中String 与Color之间的相互转换 ————————————宋兴柱     其实,我们平常如果要在数据库存放Color类型值的话,肯定会在数据库中建立varchar类型.对吧.但是Colo ...

  4. C#中string和byte[]相互转换问题解决

    本来想讲string转换为byte数组,通过在VS上打 ‘str. “来找,结果半天没发现跳出来的函数中有想要的,哭瞎 /(ㄒoㄒ)/~~ 这回将两种情况都记下来了.... string ---> ...

  5. String转Color

    原文:String转Color 很硬性的转换,谁知道更好的忘不吝赐教啊. /// <summary> /// String To Color /// </summary> // ...

  6. String与StringBuilder相互转换以及获取字符串中第一个中文汉字

    String与StringBuilder相互转换 1. StringBuilder转为String StringBuilder sb = new StringBuilder(); sb.append( ...

  7. WPF string,color,brush之间的转换

    String转换成Color string-"ffffff" Color color = (Color)ColorConverter.ConvertFromString(strin ...

  8. C# Brush Color String 互相转换

    using System.Windows.Media; //String转换成Color Color color = (Color)ColorConverter.ConvertFromString(s ...

  9. string 至 Color 转换演示示例:

    string colorstr = "#FF4D4D4D";string hex = colorstr.ToString().Replace("#", &quo ...

随机推荐

  1. C++11包装引用

    [C++11包装引用] 我们可以通过实体化样板类 reference_wrapper 得到一个包装引用 (wrapper reference).包装引用类似于一般的引用.对于任意对象,我们可以通过模板 ...

  2. C# Devexpress学习--LabelControl

    A LabelControl can display an image (regular or animated GIF file). Different images can be provided ...

  3. 使用struts dojo ajax源码案例

    我这里使用的jar 包struts2-dojo-plugin-2.2.1.1.jar ===========jsp======================= <%@ taglib prefi ...

  4. 启动tomcat时 一闪而过解决方法

    1 首先确定JAVA 已经配好了环境变量,具体配置方法,找一下度娘. 测试方法:进入cmd -> javac -version 能看到JAVA的版本信息,证明配置成功了. 2 分析一下问题出现的 ...

  5. OC:面向对象的编程思想、基本的知识点总结、强,弱引用

    OC 面向对象 和 面向过程 参考 面向过程:使用步骤划分功能,然后用函数一步一步的调用 面向对象:OOP (Object Oriented Programming) 使用功能来简化问题, 面向对象语 ...

  6. [转载]SQL Server内核架构剖析

    原文链接:http://www.sqlserver.com.cn 我们做管理软件的,主要核心就在数据存储管理上.所以数据库设计是我们的重中之重.为了让我们的管理软件能够稳定.可扩展.性能优秀.可跟踪排 ...

  7. 用Log4Net记录NHibernate中执行的SQL语句及执行时间

    首页,在web.config中加入以下配置: <configuration> <configSections> <section name="log4net&q ...

  8. opennebula 出错截图与调试

  9. IC开短路测试(open_short_test),编程器测试接触不良、开短路

    http://kitebee.meibu.com/forum.php?mod=viewthread&tid=69654&extra=page%3D5 IC开短路测试(open_shor ...

  10. UESTC 890 Card Trick(DP 纸牌魔术)

    题意  给你一些牌  所有正面朝下放桌子上   你选一个起点    翻开那张牌   牌上的数字是几就向前走几步   J,Q,K 都是向前走10步  A向前走11步   知道向前走相应的步数后超过了终点 ...