I have a menu item which has children menu items. When one of the menu items clicked, an event will be fired and do something according to the index of clicked menu item. I have seen such applications but in those cases name of menu item was criterion not index. I want something like this:
private void MI_Click (object sender, RoutedEventArgs e)
{
MenuItem mnu = (MenuItem)e.OriginalSource;
switch (mnu.Items.Index) // I know there is no such thing
{
case 0: {// do something}
case 1: {// do something}
// and so on
}
}
You could try something like this:
And in code:
EDIT:
To change the
Tagof already createdMenuItemsyou could use this:where
miis the name of the parent Menu