Instead of setting up event handlers on all the MenuItems you can listen to those events as they bubble up to the context menu as follows:
[XAML]
MenuItem1
MenuItem2
MenuItem3
MenuItem4
Or you can setup the same thing in code as follows:
[C#]
menuItem1.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(MnItem_Click));
The event handler would then be something like:
private void MnItem_Click(object sender, RoutedEventArgs e)
{
MenuItem item = e.Source as MenuItem;
....
}
Share with