title: WPF: designer won't set custom property
body: <p>In my WPF appp, I created a custom control by subclassing TextBox. I then added a DependencyProperty called BorderWhenRequired (the border to use when the TextBox represents a required field), like so:</p>
  
  <pre><code>public class TextBoxEx : TextBox
  {
      public static readonly DependencyProperty BorderWhenRequiredProperty = DependencyProperty.Register(
          "BorderWhenRequired", typeof(Brush), typeof(TextBoxEx),
          new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.AffectsRender)
      );
  
      public Brush BorderWhenRequired
      {
          get { return (Brush)GetValue(BorderWhenRequiredProperty); }
          set { SetValue(BorderWhenRequiredProperty, value); }
      }
  }
  </code></pre>
  
  <p>I then created a resource that holds the brush value for the border, and a style for the control:</p>
  
  <pre><code>&lt;SolidColorBrush x:Key="RequiredControlBorderBrush"&gt;Purple&lt;/SolidColorBrush&gt;
  
  &lt;Style TargetType="{x:Type implementations:TextBoxEx}"&gt;
      &lt;Setter Property="BorderWhenRequired" Value="{StaticResource RequiredControlBorderBrush}" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>but the designer is showing me:</p>
  
  <pre><code>ArgumentException: '#FF800080' is not a valid value for the 'MyNs.Common.Controls.Implementations.TextBoxEx.BorderWhenRequired' property on a Setter.
  </code></pre>
  
  <p>I tried defining the resource <code>RequiredControlBorderBrush</code> as a Brush, Color and SolidColorBrush, but I keep getting the same error.</p>