每当菜单项的子菜单打开时,我都想处理一个事件。关闭也一样。我怎样才能做到这一点?
最佳答案
很容易。订阅MenuItem
的SubmenuOpened
事件。传统方式:
MidItem.SubmenuOpened += new RoutedEventHandler(MidItem_SubmenuOpened);
private void MidItem_SubmenuOpened(object sender, RoutedEventArgs e)
{
//Menu Open Logic Here
}
还是很酷的动态方法:
MidItem.SubmenuOpened += delegate(object sender, RoutedEventArgs e)
{
//Menu Open Logic Here
};
关于c# - 菜单项打开和关闭事件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2287328/