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. 相反地,會引發事件,從 「 擁有 」 做為屬性的內容功能表,並只會在使用者嘗試關閉 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. 但是它有可能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.

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 - 委派Delegate ContextMenuEventHandler

適用於

另請參閱