ToolTipService.ToolTipClosingEvent 字段

定义

标识由使用 ToolTipClosing 服务显示工具提示的对象公开的 ToolTipService 事件。

public: static initonly System::Windows::RoutedEvent ^ ToolTipClosingEvent;
public static readonly System.Windows.RoutedEvent ToolTipClosingEvent;
 staticval mutable ToolTipClosingEvent : System.Windows.RoutedEvent
Public Shared ReadOnly ToolTipClosingEvent As RoutedEvent 

字段值

示例

下面的示例演示如何为 ToolTipClosing 事件设置事件处理程序。 在这种情况下,事件处理程序实际上适用于 FrameworkElement.ToolTipClosing,因为 Ellipse 附加处理程序的 是 的 FrameworkElement派生类。

ellipse2.AddHandler(ToolTipService.ToolTipOpeningEvent,
    new RoutedEventHandler(whenToolTipOpens));
ellipse2.AddHandler(ToolTipService.ToolTipClosingEvent,
    new RoutedEventHandler(whenToolTipCloses));
ellipse2.AddHandler(ToolTipService.ToolTipOpeningEvent, New RoutedEventHandler(AddressOf whenToolTipOpens))
ellipse2.AddHandler(ToolTipService.ToolTipClosingEvent, New RoutedEventHandler(AddressOf whenToolTipCloses))

void whenToolTipOpens(object sender, RoutedEventArgs e)
{
    Ellipse ell = new Ellipse();
    if (sender.GetType().FullName.Equals("System.Windows.Shapes.Ellipse"))
    {
        ell = (Ellipse)sender;
        ell.Fill = Brushes.Blue;
    }
    else if (sender.GetType().FullName.Equals(
                             "System.Windows.Controls.ToolTip"))
    {
        ToolTip t = (ToolTip)sender;
        Popup p = (Popup)t.Parent;
        ell = (Ellipse)p.PlacementTarget;
        ell.Fill = Brushes.Blue;
    }
}

void whenToolTipCloses(object sender, RoutedEventArgs e)
{
    Ellipse ell = new Ellipse();
    if (sender.GetType().FullName.Equals(
                      "System.Windows.Shapes.Ellipse"))
    {
        ell = (Ellipse)sender;
        ell.Fill = Brushes.Gray;
    }
    else if (sender.GetType().FullName.Equals(
                           "System.Windows.Controls.ToolTip"))
    {
        ToolTip t = (ToolTip)sender;
        Popup p = (Popup)t.Parent;
        ell = (Ellipse)p.PlacementTarget;
        ell.Fill = Brushes.Gray;
    }
}

Private Sub whenToolTipOpens(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim ell As New Ellipse()
    If sender.GetType().FullName.Equals("System.Windows.Shapes.Ellipse") Then
        ell = CType(sender, Ellipse)
        ell.Fill = Brushes.Blue
    ElseIf sender.GetType().FullName.Equals("System.Windows.Controls.ToolTip") Then
        Dim t As ToolTip = CType(sender, ToolTip)
        Dim p As Popup = CType(t.Parent, Popup)
        ell = CType(p.PlacementTarget, Ellipse)
        ell.Fill = Brushes.Blue
    End If
End Sub

Private Sub whenToolTipCloses(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim ell As New Ellipse()
    If sender.GetType().FullName.Equals("System.Windows.Shapes.Ellipse") Then
        ell = CType(sender, Ellipse)
        ell.Fill = Brushes.Gray
    ElseIf sender.GetType().FullName.Equals("System.Windows.Controls.ToolTip") Then
        Dim t As ToolTip = CType(sender, ToolTip)
        Dim p As Popup = CType(t.Parent, Popup)
        ell = CType(p.PlacementTarget, Ellipse)
        ell.Fill = Brushes.Gray
    End If
End Sub

注解

事件发生 ToolTipClosing 在工具提示关闭之前。

此字段为使用此服务的类注册 事件的行为 ToolTipClosingEventFrameworkElementFrameworkContentElement 类都实现 ToolTipService 并通过公共语言运行时 (CLR) 访问器和 FrameworkElement.ToolTipClosingFrameworkContentElement.ToolTipClosing公开此事件。

如果将工具提示指定为 ToolTip 对象,则 Closed 关闭工具提示时也会引发 事件。

适用于

另请参阅