title: Binding fails when using SolidColorBrush resource on Stroke property
body: <p>I have created a <code>UserControl</code> and have quite a few bindings to several custom DependencyProperties in the control. For some reason though, one of these is failing with the error:</p>
  
  <blockquote>
    <p>System.Windows.Data Error: 4 : Cannot find source for binding with
    reference 'ElementName=YearSelectorControl'.
    BindingExpression:Path=SelectedBorderColor; DataItem=null; target
    element is 'SolidColorBrush' (HashCode=45568629); target property is
    'Color' (type 'Color')</p>
  </blockquote>
  
  <p>The control includes a <code>ToggleButton</code> and <code>Popup</code>. The error occurs when the <code>Popup</code> is opened by clicking on the <code>ToggleButton</code>.</p>
  
  <p>Here is the xaml:</p>
  
  <pre><code>&lt;UserControl x:Class="MyProject.Views.YearSelector"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               xmlns:local="clr-namespace:MyProject.Views"
               mc:Ignorable="d" 
               d:DesignHeight="23" d:DesignWidth="181"
               x:Name="YearSelectorControl"&gt;
      &lt;UserControl.Resources&gt;
          &lt;SolidColorBrush x:Key="HoverColorBrush" Color="{Binding ElementName=YearSelectorControl, Path=HoverColor}"/&gt; &lt;!--This binding is virtually identical, but works fine--&gt;
          &lt;SolidColorBrush x:Key="SelectedBorderColorBrush" Color="{Binding ElementName=YearSelectorControl, Path=SelectedBorderColor}"/&gt; &lt;!--This is the binding that fails--&gt;
          &lt;local:YearToBackColorConverter x:Key="YearToBackColorConverter"/&gt;
          &lt;local:YearToBorderThicknessConverter x:Key="YearToBorderThicknessConverter"/&gt;
  
          &lt;Style x:Key="ForwardBackButtons" TargetType="{x:Type Button}" &gt;
              &lt;Setter Property="Background" Value="Transparent" /&gt;
              &lt;Setter Property="BorderThickness" Value="0" /&gt;
              &lt;Setter Property="FontFamily" Value="Arial" /&gt;
          &lt;/Style&gt;
          &lt;ControlTemplate x:Key="YearButton" TargetType="{x:Type Button}"&gt;
              &lt;Grid Width="55" Height="30" Margin="2"&gt;
                  &lt;Rectangle x:Name="ButtonRectangle" Stroke="{StaticResource SelectedBorderColorBrush}"&gt; &lt;!--Use of the failing brush--&gt;
                     &lt;!--Removed code that determines StrokeThickness. Works correctly if Stroke set to a specific color rather than a Static Resource--&gt;
                  &lt;/Rectangle&gt;
                  &lt;ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/&gt;
              &lt;/Grid&gt;
              &lt;ControlTemplate.Triggers&gt;
                  &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                      &lt;Setter TargetName="ButtonRectangle" Property="Fill" Value="{StaticResource HoverColorBrush}"/&gt; &lt;!--Use of the properly binding brush--&gt;
                  &lt;/Trigger&gt;
              &lt;/ControlTemplate.Triggers&gt;
          &lt;/ControlTemplate&gt;
      &lt;/UserControl.Resources&gt;
  
      &lt;Grid&gt;
          &lt;!--Layout here--&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Here is an excerpt from the code-behind for the two <code>DependencyProperties</code> that are bound to <code>SolidColorBrush</code> resources:</p>
  
  <pre><code>public Color HoverColor
  {
      get { return (Color)GetValue(HoverColorProperty); }
      set { SetValue(HoverColorProperty, value); }
  }
  public static readonly DependencyProperty HoverColorProperty = 
      DependencyProperty.Register("HoverColor", typeof(Color), typeof(YearSelector), new PropertyMetadata(Color.FromArgb(255,190,230,253)));
  
  public Color SelectedBorderColor
  {
      get { return (Color)GetValue(SelectedBorderColorProperty); }
      set { SetValue(SelectedBorderColorProperty, value); }
  }
  public static readonly DependencyProperty SelectedBorderColorProperty = 
      DependencyProperty.Register("SelectedBorderColor", typeof(Color), typeof(YearSelector), new PropertyMetadata(Color.FromArgb(255,126,0,234)));
  </code></pre>