FrameworkElement.ToolTipOpening 事件

定义

在元素上的任何工具提示打开时发生。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 

注解

为了防止工具提示在 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. 这是因为此事件的 "标识符" 字段会重新使用服务中的实现,该实现不会公开服务级别事件的 add/remove 事件方法。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

适用于

另请参阅