FrameworkElement.OnContextMenuClosing(ContextMenuEventArgs) 方法

定义

每当未处理的 ContextMenuClosing 路由事件在其路由中到达此类时调用。Invoked whenever an unhandled ContextMenuClosing routed event reaches this class in its route. 实现此方法可为此事件添加类处理。Implement this method to add class handling for this event.

protected:
 virtual void OnContextMenuClosing(System::Windows::Controls::ContextMenuEventArgs ^ e);
protected virtual void OnContextMenuClosing (System.Windows.Controls.ContextMenuEventArgs e);
abstract member OnContextMenuClosing : System.Windows.Controls.ContextMenuEventArgs -> unit
override this.OnContextMenuClosing : System.Windows.Controls.ContextMenuEventArgs -> unit
Protected Overridable Sub OnContextMenuClosing (e As ContextMenuEventArgs)

参数

e
ContextMenuEventArgs

提供与事件有关的数据。Provides data about the event.

注解

此方法没有默认实现。This method has no default implementation. 如果继承中的中间类已经实现了此方法,则仍应调用基实现。You should still call the base implementation in case an intermediate class in the inheritance has implemented this method.

此方法的目的有些类似于 * 方法上 公共语言运行时 (CLR)common language runtime (CLR) 事件模式:它提供了用类处理程序而不是实例处理程序来处理来自派生类的匹配事件的方法。The purpose of this method is somewhat similar to 公共语言运行时 (CLR)common language runtime (CLR) event pattern On* methods: it provides the means to handle the matching event from derived classes with a class handler instead of an instance handler. 在这种情况下,匹配事件是路由事件。In this case the matching event is a routed event. 对于路由事件,On * 方法的实现模式是不同的,因为路由事件可能是由子元素引发的,而不一定是将调用处理程序的元素,因此实现需要采用事件参数 "source属性(在大多数情况下,不应尝试重新引发事件)。The implementation pattern of the On* methods is different for routed events because the routed event may have been raised by a child element, not necessarily the element that will invoke handlers, so your implementation will need to take the event arguments' source properties into account (and should not try to re-raise the event in most cases). 当沿路由收到事件时,FrameworkElement 的子类可以选择调用私有类处理程序方法。Subclasses of FrameworkElement could choose to call private class handler methods when the event is received along the route. 一种可能的情况是采用事件的参数,并特意将事件标记为已处理。One potential scenario is to take the arguments of the event and deliberately mark the event as handled.

适用于