{"id":972,"date":"2019-11-20T20:00:29","date_gmt":"2019-11-20T20:00:29","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=972"},"modified":"2019-11-20T20:00:29","modified_gmt":"2019-11-20T20:00:29","slug":"brush-colours","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/color\/brush-colours","title":{"rendered":"Brush Colours"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Objects that use a brush color<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>.Foreground<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Setting A Brush Color<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tMyTextBlock.Foreground = new SolidColorBrush(Colors.White);    \/\/&lt;&lt;&lt;Note its Colors, not Color!\n\n\tMyTextBlock.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Using a const defined color<\/h4>\n\n\n\n<p>This is actually quite hard as Color can&#8217;t be defined const and .FromArgb can&#8217;t take a Int32 in UWP.  The following achieves it<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tpublic static readonly byte&#091;] MyConstColor = new byte&#091;] { 0xff, 0xff, 0xff, 0xff };\n\n\tMyTextBlock.Foreground = new SolidColorBrush(Color.FromArgb(MyConstColor&#091;0], MyConstColor&#091;1], MyConstColor&#091;2], MyConstColor&#091;3]));<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Objects that use a brush color Setting A Brush Color Using a const defined color This is actually quite hard as Color can&#8217;t be defined const and .FromArgb can&#8217;t take a Int32 in UWP. The following achieves it<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[91],"tags":[],"class_list":["post-972","post","type-post","status-publish","format-standard","hentry","category-color"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=972"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/972\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}