FrameworkElement.ContextMenuClosing FrameworkElement.ContextMenuClosing FrameworkElement.ContextMenuClosing FrameworkElement.ContextMenuClosing Event

定义

在元素上的任何上下文菜单关闭之前发生。Occurs just before any context menu on the element is closed.

public:
 event System::Windows::Controls::ContextMenuEventHandler ^ ContextMenuClosing;
public event System.Windows.Controls.ContextMenuEventHandler ContextMenuClosing;
member this.ContextMenuClosing : System.Windows.Controls.ContextMenuEventHandler 
Public Custom Event ContextMenuClosing As ContextMenuEventHandler 

注解

若要取消关闭上下文菜单, 该事件的处理程序应将其标记为已处理。To suppress closing context menus, handlers of the event should mark it as handled.

若要EventTrigger在样式中使用此事件, 必须引用事件的基础服务定义:To use this event as an EventTrigger in a style, you must reference the underlying service's definition of the event:

<EventTrigger RoutedEvent="ContextMenuService.ContextMenuClosing">
  <!-- storyboard here ... -->
</EventTrigger>

(这种用法是必需的FrameworkElement , 因为公开基础服务事件的中的事件实现不ContextMenuClosing映射标识符, 因此你可以将其用作触发器)。(This usage is required because the event implementation on FrameworkElement that exposes the underlying service event does not map the ContextMenuClosing identifier such that you can use it as a trigger).

ContextMenu本身是一个FrameworkElement派生类, 但该ContextMenuClosing事件不会直接由上下文菜单引发。ContextMenu itself is a FrameworkElement derived class, but the ContextMenuClosing event will not be raised by a context menu directly. 相反, 事件是从 "拥有" 上下文菜单作为属性的元素引发的, 仅当用户尝试关闭用户界面菜单时才会引发。Instead, the event is raised from the element that "owns" the context menu as a property and is only raised when a user attempts to close a context menu in the UI. 不过, ContextMenu自身可能ContextMenu具有属性 (嵌套上下文菜单)。However it is possible for ContextMenu itself to have a ContextMenu property (a nested context menu). 在这种情况ContextMenu下, 确实拥有嵌套ContextMenu的, 可能引发事件, 并将事件的源作为嵌套上下文菜单。In this case the ContextMenu really does own the nested ContextMenu and might raise the event, with the source of the event being the nested context menu.

类本身也具有类似事件 (Closed), 但Closed事件不提供取消用户操作的机会。 ContextMenuThe ContextMenu class itself also has a similar event (Closed) but the Closed event does not provide you the opportunity to cancel the user action.

路由事件信息Routed Event Information

标识符字段Identifier field ContextMenuClosingEvent
路由策略Routing strategy 冒泡Bubbling
委托Delegate ContextMenuEventHandler

适用于

另请参阅