When I tried the above code, the error I got was:
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 Click event, or add a x:Class attribute to the root element. Line 10 Position 35
This is how I fixed it:
1) Added x:Class attribute to the ResourceDictionary
:
x:Class="WpfApplication4.Dictionary1"
2) Added a C# class file to the project, Code below:
public partial class Dictionary1 : ResourceDictionary
{
public Dictionary1()
{
InitializeComponent();
}
void OnMenuItemClick(object sender, RoutedEventArgs e)
{
}
}
And then, the project built fine.