1

我从 ContextMenu 派生,在派生类中我需要手动引发 ContextMenuClosing 事件。我尝试了以下两种方法:

// On runtime tells me it can't convert from  
// "System.Windows.RoutedEventArgs" to 
// "System.Windows.Controls.ContextMenuEventArgs"
RaiseEvent(new RoutedEventArgs(ContextMenuClosingEvent));

// Second attempt: On compile time tells me,
// there's no constructor for ContextMenuEventArgs
OnContextMenuClosing(new ContextMenuEventArgs());

我是 RoutedEvents 的新手,有人可以帮我如何手动引发 ContextMenuClosing 事件吗?谢谢!

4

1 回答 1

0

这个问题中,海报显示了他似乎能够实例化 ContextMenuEventArgs 的代码,即使它的构造函数是私有的

于 2010-08-01T21:11:30.930 回答