ToolTipService.ToolTipClosingEvent 欄位
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
識別由使用 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 會在工具提示關閉之前立即發生。
此欄位會針對使用此服務之 ToolTipClosingEvent 類別註冊事件的行為。 和 FrameworkElementFrameworkContentElement 類別都會透過 Common Language Runtime (CLR) 存取子 FrameworkElement.ToolTipClosing 和 FrameworkContentElement.ToolTipClosing 來實 ToolTipService 作 和 公開此事件。
如果您將工具提示指定為 ToolTip 物件, Closed 當工具提示關閉時也會引發 事件。