Hi,
I have a context menu that's bound to a list of strings so that each menuitem's text is an element of the string list. Each menuitem is set to the same event handler. What I'm trying to do is to figure out is which menu item was clicked when when the event handler is called.
I would think it would be pretty straight forward to do, but I'm a bit stumped.
If I look at the watch window, there's a menuitem property called FocusedItem. It has the information I need but when I try to use it it doesn't seem to be part of the class and the code doesn't even compile, which I find strange.
Can someone point me in the right direction?
The bit of xaml and code I'm having trouble with:
<MenuItem Header="Add Object" ItemsSource="{Binding ObjectClassList}" Click="AddObject_Click"/>
private void AddObject_Click(object sender, RoutedEventArgs e)
{
MenuItem menuItem = sender as MenuItem;
if (menuItem == null)
{
return;
}
// menuItem.FocusedItem // ?? does not compile
}
Thanks!