title: Databinding the color of a RadialGradient brush in silverlight 3
body: <p>I am trying to databind the color of a RadialGradientBrush in silverlight 3 to a property, but just can't seem to get it to work.</p>
  
  <p>For example, in a sample test app all I have is </p>
  
  <pre><code>&lt;navigation:Page x:Class="SilverlightNavigator.HomePage" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  x:Name="HomePageUC"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
         xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
         Title="HomePage Page"&gt;
  &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
          &lt;StackPanel&gt;
  
              &lt;TextBlock 
                         DataContext="{Binding ElementName=HomePageUC}" 
                          Text="{Binding TestColorOne}" /&gt;
  
          &lt;Rectangle x:Name="testRectangle" Height="100" Width="100" 
                     DataContext="{Binding ElementName=HomePageUC}" &gt;
                  &lt;Rectangle.Fill&gt;
                  &lt;RadialGradientBrush&gt;
                      &lt;GradientStop Color="{Binding TestColorOne}" Offset="0" /&gt;
                      &lt;GradientStop Color="{Binding TestColorTwo}" Offset="1"/&gt;
                      &lt;!--
                      &lt;GradientStop Color="#FFFF0000" /&gt;
                      &lt;GradientStop Color="#FF00FF00" Offset="1"/&gt;
                      --&gt;
                  &lt;/RadialGradientBrush&gt;
                  &lt;/Rectangle.Fill&gt;
              &lt;/Rectangle&gt;
  
          &lt;/StackPanel&gt;
  </code></pre>
  
  <p>In the code behind, I have even made them dependency properties like this ..</p>
  
  <pre><code>    public static readonly DependencyProperty TestColorOneProperty =
          DependencyProperty.RegisterAttached("TestColorOne", typeof(Color), typeof(HomePage), null);
  
      public static readonly DependencyProperty TestColorTwoProperty =
          DependencyProperty.RegisterAttached("TestColorTwo", typeof(Color), typeof(HomePage), null);
  
  
      public Color TestColorOne
      {
          get { return (Color)GetValue(TestColorOneProperty); }
          set { SetValue(TestColorOneProperty, value); }
      }
  
      public Color TestColorTwo
      {
          get { return (Color)GetValue(TestColorTwoProperty); }
          set { SetValue(TestColorTwoProperty, value); }
      }
  </code></pre>
  
  <p>But this still gives me the very unhelpful AG_E_PARSER_BAD_PROPERTY_VALUE exception. If I uncomment the two Xaml lines where the colors are hard coded, it works fine. I know the properties are fine because if I hard code the colors or comment out the rectangle, it displays the text fine. (Via the binding to the TextBlock) </p>
  
  <p>I have also tried passing in the string "Red", "Blue" etc. instead of the color object. But the binding just doesn't seem to work.</p>
  
  <p>Any advice?</p>