title: WPF DataGrid - Color Cells on Graded Color Scale
body: <p>I'm trying to figure out if there is a way to color individual cells on a color scale.  In particular, I am hoping to get something like the Bonus column in the following:</p>
  
  <p><img src="https://i.stack.imgur.com/Ssafa.png" alt="Color scale example"></p>
  
  <p>Currently, I've setup my datagrid's columns background property to bind to the following converter:</p>
  
  <pre><code>        public class NameToBrushConverter : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
          {
              double? input = value as double?;
              if(input&lt;-5)
              {
                  return Brushes.MediumVioletRed;
              }
              if(-5&lt;=input &amp;&amp; input&lt;-0.5)
              { 
                  return Brushes.IndianRed;
              }
              if (.5 &lt;= input &amp;&amp; input &lt; 5)
              { 
                  return Brushes.LightGreen; 
              }
              if (5 &lt;= input)
              { 
                  return Brushes.LawnGreen; 
              } 
  
               return DependencyProperty.UnsetValue;            
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
          {
              throw new NotSupportedException();
          }
      }
  }
  </code></pre>
  
  <p>Is there a way, without hard coding the values, to get a color scale? </p>
  
  <p>Thanks - kcross</p>
  
  <p>EDIT: I'm also trying to create a better Red-Green color scale (ie for negative to positive numbers),  in terms of one that is a little less hard on the eyes.... if anyone has any suggestions on that as well that's also appreciated!</p>