I want to handle an event, whenever the Submenus of a menu item opens. Same for closing. how can I do this?
Very easy. Subscribe to a MenuItem's SubmenuOpened event. Traditional way to do it:
MidItem.SubmenuOpened += new RoutedEventHandler(MidItem_SubmenuOpened);
private void MidItem_SubmenuOpened(object sender, RoutedEventArgs e)
{
//Menu Open Logic Here
}
Or the cool dynamic method:
MidItem.SubmenuOpened += delegate(object sender, RoutedEventArgs e)
{
//Menu Open Logic Here
};
Not sure what you want, but take a look at these events for ContextMenu and MenuItem:
ContextMenu:
http://msdn.microsoft.com/en-us/library/system.windows.controls.contextmenu_events.aspx
MenuItem:
http://msdn.microsoft.com/en-us/library/system.windows.controls.menuitem_events.aspx
I think ContextMenuOpening and ContextMenuClosing might be interesting ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With