手动引发 ContextMenuClosing 事件
我从 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 事件吗?谢谢!
I'm deriving from ContextMenu and inside the derived class I need to raise the ContextMenuClosing event manually. I tried the following two ways:
// 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());
I'm new to RoutedEvents, can someone please help me how to raise the ContextMenuClosing event manually? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这个问题中,海报显示了他似乎能够使用的代码实例化 ContextMenuEventArgs,即使它的构造函数是私有的
In this question the poster shows code in which he seems to be able to instantiate ContextMenuEventArgs even though its constructor is private