title: Binding Gradient color in wpf
body: <p>I have to bind the gradient color property. In this I am using a converter. Here is the xaml code for binding</p>
  
  <pre><code>&lt;GradientStop Color="{Binding Namevalue, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource nametocolorconverter}}"/&gt;
  </code></pre>
  
  <p>the code for nametocolorconverter</p>
  
  <pre><code>class nametocolorconverter: IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
         Brush brw = new Brush();
          if(value == "Blue") brw = Colors.Blue;
          elseif(value=="Green") brw = Colors.Green;
          else brw=Colors.Red;
     return brw;
  
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
          return null;
      }
  </code></pre>
  
  <p>The above code is not working. I am not getting the desired color.</p>