ToolTip.Opened 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當 ToolTip 變成可見時發生。
public:
event System::Windows::RoutedEventHandler ^ Opened;
public event System.Windows.RoutedEventHandler Opened;
member this.Opened : System.Windows.RoutedEventHandler
Public Custom Event Opened As RoutedEventHandler
事件類型
範例
下列範例示範如何設定 和 Closed 事件的事件處理常式 Opened 。
tooltip.Opened +=
new RoutedEventHandler(whenToolTipOpens);
tooltip.Closed +=
new RoutedEventHandler(whenToolTipCloses);
AddHandler tooltip.Opened, AddressOf whenToolTipOpens
AddHandler tooltip.Closed, 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
備註
當 FrameworkElement.ToolTipOpening 控制項開啟時 ToolTip ,也會引發 事件。
路由事件資訊
識別碼欄位 | OpenedEvent |
路由策略 | 鼓 泡 |
代理人 | RoutedEventHandler |