FrameworkElement.ToolTipOpening Event

Definition

任何元素的工具提示開啟時發生。Occurs when any tooltip on the element is opened.

public:
 event System::Windows::Controls::ToolTipEventHandler ^ ToolTipOpening;
public event System.Windows.Controls.ToolTipEventHandler ToolTipOpening;
member this.ToolTipOpening : System.Windows.Controls.ToolTipEventHandler 
Public Custom Event ToolTipOpening As ToolTipEventHandler 

Remarks

為避免 UI 中出現工具提示,ToolTipOpening 的處理常式可以標示已處理的 ToolTipEventArgs 事件資料。To prevent a tooltip from appearing in the UI, your handler for ToolTipOpening can mark the ToolTipEventArgs event data handled. 否則,會使用 [ToolTip] 屬性的值做為工具提示內容,以顯示工具提示。Otherwise, the tooltip is displayed, using the value of the ToolTip property as the tooltip content. 另一個可能的情況是,您可以撰寫處理常式,在顯示工具提示之前,重設為事件來源之元素的 ToolTip 屬性值。Another possible scenario is that you could write a handler that resets the value of the ToolTip property for the element that is the event source, just before the tooltip is displayed.

如果 ToolTip 的值 null 或未設定,則不會引發 ToolTipOpeningToolTipOpening will not be raised if the value of ToolTip is null or otherwise unset. 當工具提示開啟或開啟時,不要刻意將 ToolTip 設定為 null;這不會影響關閉工具提示,而是改為在 UI 中建立不想要的視覺效果成品。Do not deliberately set ToolTip to null while a tooltip is open or opening; this will not have the effect of closing the tooltip, and will instead create an undesirable visual artifact in the UI.

ToolTipOpening 事件不可以是樣式中的 EventTriggerThe ToolTipOpening event cannot be an EventTrigger in a style. 這是因為此事件的 [識別碼] 欄位會從服務中重新使用不公開服務層級事件之新增/移除事件方法的執行。This is because the identifier field of this event re-uses an implementation from a service that does not expose add/remove event methods for the service-level event.

路由事件資訊Routed Event Information

識別碼欄位Identifier field ToolTipOpeningEvent
路由策略Routing strategy 直接Direct
委派Delegate ToolTipEventHandler
  • 覆寫 OnToolTipClosing,以在衍生類別中為這個事件執行類別處理。Override OnToolTipClosing to implement class handling for this event in derived classes.

Applies to

See also