{"id":76,"date":"2015-06-18T22:21:39","date_gmt":"2015-06-18T14:21:39","guid":{"rendered":"https:\/\/blog.freesilo.com\/?p=76"},"modified":"2015-06-18T22:21:39","modified_gmt":"2015-06-18T14:21:39","slug":"wpf%e5%ad%97%e7%ac%a6%e4%b8%b2%ef%bc%8ccolor%ef%bc%8cbrush%e4%b9%8b%e9%97%b4%e7%9a%84%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/freesilo.com\/?p=76","title":{"rendered":"WPF\u5b57\u7b26\u4e32\uff0ccolor\uff0cbrush\u4e4b\u95f4\u7684\u8f6c\u6362"},"content":{"rendered":"<p>1\uff0c\u5c06#3C3C3C \u8d4b\u7ed9background<\/p>\n<div>\n<pre>this.selectBook.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(\"#3C3C3C\"));<\/pre>\n<\/div>\n<p>2\uff0ccolordialog\u4e2d\u7684\u503c(ARGB)\u8f6c\u6362\u4e3aBrush<\/p>\n<div>\n<pre>Brush br = new SolidColorBrush(Color.FromArgb(cl.Color.A, cl.Color.R, cl.Color.G, cl.Color.B));<\/pre>\n<\/div>\n<p>3,\u793a\u4f8b\uff1a<\/p>\n<p>\u547d\u540d\u7a7a\u95f4\uff1a<\/p>\n<p>using System.Windows.Media;<\/p>\n<p>1)\u3001<strong>String\u8f6c\u6362\u6210Color<\/strong><\/p>\n<div>\n<pre>Color color = (Color)ColorConverter.ConvertFromString(string);<\/pre>\n<\/div>\n<p>2)\u3001<strong>String\u8f6c\u6362\u6210Brush<\/strong><\/p>\n<div>\n<pre>BrushConverter brushConverter = new BrushConverter();\nBrush brush = (Brush)brushConverter.ConvertFromString(string);<\/pre>\n<\/div>\n<p>3)\u3001<strong>Color\u8f6c\u6362\u6210Brush<\/strong><\/p>\n<div>\n<pre>Brush brush = new SolidColorBrush(color));<\/pre>\n<\/div>\n<p>4)\u3001<strong>Brush\u8f6c\u6362\u6210Color\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a<\/strong><\/p>\n<div>\n<div><\/div>\n<pre>\/\/\u5148\u5c06Brush\u8f6c\u6210string\uff0c\u518d\u8f6c\u6210Color\u3002\n\n Color color= (Color)ColorConverter.ConvertFromString(brush.ToString());\n\n\/\/\u5c06Brush\u8f6c\u6210SolidColorBrush\uff0c\u518d\u53d6Color\u3002\n\n Color color= ((SolidColorBrush)CadColor.Background).Color;<\/pre>\n<\/div>\n<p>\u672c\u6587\u6765\u81ea\u5e73\u6c11\u603b\u6709\u5d1b\u8d77\u7684\u65f6\u5019\u7684\u535a\u5ba2\uff0c\u539f\u6587\u5730\u5740:http:\/\/www.cnblogs.com\/wj-love\/archive\/2012\/09\/14\/2685281.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\uff0c\u5c06#3C3C3C \u8d4b\u7ed9background this.selectBook&#8230;.<br \/><a class=\"read-more-button\" href=\"https:\/\/freesilo.com\/?p=76\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-wpf"],"_links":{"self":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":0,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}