Прочетете на английски Редактиране

Споделяне чрез


ToolTipService.ToolTipClosingEvent Field

Definition

Identifies the ToolTipClosing event that is exposed by objects that use the ToolTipService service to display tooltips.

C#
public static readonly System.Windows.RoutedEvent ToolTipClosingEvent;

Field Value

Examples

The following example shows how to set an event handler for the ToolTipClosing event. In this case, the event handler is actually for FrameworkElement.ToolTipClosing, because the Ellipse where the handler is attached is a derived class of FrameworkElement.

C#
ellipse2.AddHandler(ToolTipService.ToolTipOpeningEvent,
    new RoutedEventHandler(whenToolTipOpens));
ellipse2.AddHandler(ToolTipService.ToolTipClosingEvent,
    new RoutedEventHandler(whenToolTipCloses));
C#

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;
    }
}

Remarks

The ToolTipClosing event occurs immediately before a tooltip closes.

This field registers the behavior of the ToolTipClosingEvent event for classes that use this service. The FrameworkElement and FrameworkContentElement classes both implement the ToolTipService and expose this event through the common language runtime (CLR) accessors FrameworkElement.ToolTipClosing and FrameworkContentElement.ToolTipClosing.

If you specify the tooltip as a ToolTip object, the Closed event is also raised when the tooltip closes.

Applies to

Продукт Версии
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also