{"id":69,"date":"2011-03-10T05:21:00","date_gmt":"2011-03-10T05:21:00","guid":{"rendered":"http:\/\/www.mishmashmakers.com\/michelle\/?p=69"},"modified":"2017-02-08T14:53:23","modified_gmt":"2017-02-08T19:53:23","slug":"convert-system-windows-media-brush-to-system-windows-media-color-and-vice-versa","status":"publish","type":"post","link":"https:\/\/www.mishmashmakers.com\/michelle\/2011\/03\/convert-system-windows-media-brush-to-system-windows-media-color-and-vice-versa\/","title":{"rendered":"Convert System.Windows.Media.Brush to System.Windows.Media.Color and vice versa"},"content":{"rendered":"<body><p><\/p>I am working on a project that uses C# and WPF and I have been having one hella time on one small technical problem: converting between different classes of colors.\u00a0All I needed to do was convert from a\u00a0System.Windows.Media.Brush to System.Windows.Media.Color in one part of my code and then convert from my System.Windows.Media.Color back to a System.Windows.Media.Brush in another part of the code. Needless to say, it was easy to go from Color to Brush but not from Brush to Color (I searched high and low using Google but had zero luck \u2013 hence my post on the topic!).\n<p><a style=\"margin-left: auto; margin-right: auto;\" href=\"https:\/\/i0.wp.com\/1.bp.blogspot.com\/-RcPp5aco43Q\/ToJk7sL2oeI\/AAAAAAAAAns\/OOhodHb2Tg4\/s1600\/tumblr_laplj9TRso1qb2g4vo1_500_large.jpg\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i0.wp.com\/1.bp.blogspot.com\/-RcPp5aco43Q\/ToJk7sL2oeI\/AAAAAAAAAns\/OOhodHb2Tg4\/s320\/tumblr_laplj9TRso1qb2g4vo1_500_large.jpg?resize=320%2C186\" width=\"320\" height=\"186\" border=\"0\" loading=\"lazy\"><\/a><\/p>\n<p>For those out there who need it:<br>\nColor -&gt; Brush<br>\nColor newColor = Colors.Blue;<br>\nBrush imageColor = new SolidColorBrush(newColor);<\/p>\n<p>Brush -&gt; Color<br>\nBrush newColor = Brushes.Blue;<br>\nSolidColorBrush newBrush = (SolidColorBrush)newColor;<br>\nColor imageColor = newBrush.Color;<\/p>\n<p>Also, a ScatterView does not like to scale Canvas objects.<\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>I am working on a project that uses C# and WPF and I have been having one hella time on one small technical problem: converting between different classes of colors.\u00a0All I needed to do was convert from a\u00a0System.Windows.Media.Brush to System.Windows.Media.Color in one part of my code and then convert from my System.Windows.Media.Color back to a [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[48],"tags":[],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","category-other"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7fMLx-17","_links":{"self":[{"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/posts\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":3,"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":700,"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/posts\/69\/revisions\/700"}],"wp:attachment":[{"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mishmashmakers.com\/michelle\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}