title: Binding/Referencing Method to XAML WPF
body: <p>I have this xaml</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:l="clr-namespace:My.Windows"
                      &gt;
      &lt;ObjectDataProvider x:Key="TitledWindow_Test" MethodName="Test" ObjectInstance={x:Type l:TitledWindow}"&gt;
      &lt;ControlTemplate x:Key="TitledWindowControlTemplateKey" x:Name="PART_ControlTemplate" TargetType="{x:Type l:TitledWindow}"
          &lt;Rectangle&gt;
              &lt;Rectangle.Style&gt;
                  &lt;EventSetter Event="Mouse.MouseEnter" Handler="{StaticResource TitledWindow_Test}"&gt;
              &lt;/Rectangle.Style&gt;
          &lt;/Rectangle&gt;
      &lt;/ControlTemplate&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>And my c# code:</p>
  
  <pre><code>namespace My.Windows
  {
      public partial class TitledWindow : Window
      {
          public void Test()
          {
              MessageBox.Show("Test");
          }
      }
  }
  </code></pre>
  
  <p>The problem is that i get the following error: </p>
  
  <p><strong>Error 1<br>
  'ResourceDictionary' root element requires a x:Class attribute to support event
  handlers in the XAML file. Either remove the event handler for the MouseEnter event,
  or add a x:Class attribute to the root element.</strong></p>