I have this xaml
<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" > <ObjectDataProvider x:Key="TitledWindow_Test" MethodName="Test" ObjectInstance={x:Type l:TitledWindow}"> <ControlTemplate x:Key="TitledWindowControlTemplateKey" x:Name="PART_ControlTemplate" TargetType="{x:Type l:TitledWindow}" <Rectangle> <Rectangle.Style> <EventSetter Event="Mouse.MouseEnter" Handler="{StaticResource TitledWindow_Test}"> </Rectangle.Style> </Rectangle> </ControlTemplate> </ResourceDictionary> And my c# code:
namespace My.Windows { public partial class TitledWindow : Window { public void Test() { MessageBox.Show("Test"); } } } The problem is that i get the following error:
Error 1
'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.