title: Binding in WPF style causes inexplicable "Cannot find governing FrameworkElement" error
body: <p>I have an <code>ItemsControl</code> that displays a bunch of rectangles. Each rectangle needs to be offset upward and to the left. So, I created a <code>RectangleStyle</code> that uses bindings to set the width, height, X translation, and Y translation for a rectangle. </p>
  
  <p>The width and height bindings are working fine, but I'm getting the following error for the <code>TranslateTransform</code> bindings:</p>
  
  <blockquote>
    <p>System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Offset.X; DataItem=null; target element is 'TranslateTransform' (HashCode=16452547); target property is 'X' (type 'Double')</p>
  </blockquote>
  
  <p>Here is the definition of my <code>ItemControl</code>:</p>
  
  <pre><code>&lt;ItemsControl
      Style="{StaticResource ItemsControlStyle}"
      ItemsSource="{Binding Zones}"&gt;
      &lt;ItemsControl.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;Rectangle Style="{StaticResource RectangleStyle}" /&gt;
          &lt;/DataTemplate&gt;
      &lt;/ItemsControl.ItemTemplate&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>Here is the definition of <code>ItemsControlStyle</code>:</p>
  
  <pre><code>&lt;Style x:Key="ItemsControlStyle" TargetType="ItemsControl"&gt;
      &lt;Setter Property="ItemsPanel"&gt;
          &lt;Setter.Value&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;Canvas /&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Setter Property="ItemContainerStyle"&gt;
          &lt;Setter.Value&gt;
              &lt;Style&gt;
                  &lt;Setter Property="Canvas.Left" Value="{Binding Point.X}" /&gt;
                  &lt;Setter Property="Canvas.Top" Value="{Binding Point.Y}" /&gt;
              &lt;/Style&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>And here is the definition of <code>RectangleStyle</code>:</p>
  
  <pre><code>&lt;Style x:Key="RectangleStyle" TargetType="Rectangle"&gt;
      &lt;Setter Property="Width" Value="{Binding Size.Width}" /&gt;
      &lt;Setter Property="Height" Value="{Binding Size.Height}" /&gt;
      &lt;Setter Property="RenderTransform"&gt;
          &lt;Setter.Value&gt;
              &lt;!-- these bindings are causing the error --&gt;
              &lt;TranslateTransform X="{Binding Offset.X}" Y="{Binding Offset.Y}" /&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <hr>
  
  <p>The two bindings in the <code>RenderTransform</code> setter of <code>RectangleStyle</code> are the cause of the error, but I'm not sure what to do to fix the problem. Interestingly, the graphics <em>are</em> being translated properly, so WPF is able to resolve the bindings--it's just not happy about them for some reason.</p>
  
  <p>What can I do to fix the bindings?</p>
  
  <hr>
  
  <p><strong>Edit</strong></p>
  
  <p>I submitted a bug report on MS Connect:</p>
  
  <p><a href="https://connect.microsoft.com/VisualStudio/feedback/details/746840/misleading-cannot-find-governing-frameworkelement-error-message-appears-in-output-window" rel="noreferrer">https://connect.microsoft.com/VisualStudio/feedback/details/746840/misleading-cannot-find-governing-frameworkelement-error-message-appears-in-output-window</a></p>