FrameworkElement.ContextMenuClosing 事件


在項目上的任何內容功能表正要關閉之前發生。Occurs just before any context menu on the element is closed.

 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 ... -->

(這種使用方式是必要的,因為在上 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. 相反地,事件是從「擁有」內容功能表做為屬性的元素引發,而且只有在使用者嘗試關閉 UI 中的內容功能表時才會引發。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. 不過,它本身可以 ContextMenuContextMenu () 的嵌套快顯功能表屬性。However it is possible for ContextMenu itself to have a ContextMenu property (a nested context menu). 在這種情況下, ContextMenu 其實的確擁有 nested, 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.

ContextMenu類別本身也有類似的事件 (Closed) 但事件不 Closed 會讓您有機會取消使用者動作。The 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