title: Cannot find governing FrameworkElement, Yet it works like intended (WPF)
body: <p>I have a binding that gives me an error, yet everything works exactly like it should.</p>
  <p>I have a Custom Control with it's style/template in &quot;Generic.xaml&quot;, in the ControlTemplate I have the following code (as well as a lot of other irrelevant code for this question):</p>
  <pre><code>&lt;v:ColoredImage Image=&quot;{StaticResource LoadingIcon}&quot; Color=&quot;{StaticResource DarkBlueClick}&quot; RenderTransformOrigin=&quot;0.5, 0.5&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;32&quot; Height=&quot;32&quot; Margin=&quot;0,0,0,0&quot; Visibility=&quot;{Binding IsBusy, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibility}}&quot;&gt;
      &lt;v:ColoredImage.RenderTransform&gt;
          &lt;RotateTransform Angle=&quot;{Binding MainViewModel.LoadAnimAngle, RelativeSource={RelativeSource TemplatedParent}}}&quot;/&gt; //here is the error
      &lt;/v:ColoredImage.RenderTransform&gt;
  &lt;/v:ColoredImage&gt;
  </code></pre>
  <p>In the <code>ViewModel.cs</code> file for the custom control, I have this:</p>
  <pre><code>public MainViewModel MainViewModel { get { return MainViewModel.instance; } }
  </code></pre>
  <p><code>MainViewModel.instance</code> is a static reference.</p>
  <p>With this in code behind:</p>
  <pre><code>    public MainViewModel MainViewModel
      {
          get { return (MainViewModel)GetValue(MainViewModelProperty); }
          set { SetValue(MainViewModelProperty, value); }
      }
  
      public static readonly DependencyProperty MainViewModelProperty =
      DependencyProperty.Register(&quot;MainViewModel&quot;, typeof(MainViewModel),
      typeof(ComPortButton), new PropertyMetadata(null));
  </code></pre>
  <p>And in the page where I'm using this custom control, I bind it:</p>
  <pre><code>MainViewModel=&quot;{Binding MainViewModel}&quot;
  </code></pre>
  <p>I get this error:</p>
  <blockquote>
  <p>System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=MainViewModel.LoadAnimAngle; DataItem=null; target element is 'RotateTransform' (HashCode=53044787); target property is 'Angle' (type 'Double')</p>
  </blockquote>
  <p>But, everything works. The icon is spinning like it should. I just want to get rid of the error at start. Code works, but error is annoying.</p>
  <p>When searching for solutions to this, I didn't find any solutions for custom controls with template/style in generic, I found solutions to User Controls and I'm unsure on how to translate the fix. I know I need to do something with &quot;ProxyElement&quot;, but none of the solutions i found explained what it is or why it works, etc, so it's hard to translate the fix to another situation that is not exactly the same situation as the solutions I found.</p>