Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a string like "Red" to a System.Windows.Media.Color?

Tags:

wpf

I know I can go the long route by...

  1. Adding a reference to System.Drawing
  2. Creating a System.Drawing.Color from the string
  3. Creating the System.Windows.Media.Color from the ARGB values of the System.Drawing.Color.

But this feels like serious overkill.

Is there an easier way?

like image 310
willem Avatar asked Mar 23 '09 11:03

willem


1 Answers

var color = (Color)ColorConverter.ConvertFromString("Red"); 
like image 110
Kent Boogaart Avatar answered Sep 20 '22 01:09

Kent Boogaart