@@ -1580,22 +1580,38 @@ public string TooltipText
1580
1580
/// The tooltip text property
1581
1581
/// </summary>
1582
1582
public static readonly DependencyProperty TooltipTextProperty =
1583
- DependencyProperty . Register ( nameof ( TooltipText ) , typeof ( string ) , typeof ( ChromiumWebBrowser ) , new PropertyMetadata ( null , ( sender , e ) => ( ( ChromiumWebBrowser ) sender ) . OnTooltipTextChanged ( ) ) ) ;
1583
+ DependencyProperty . Register ( nameof ( TooltipText ) , typeof ( string ) , typeof ( ChromiumWebBrowser ) , new PropertyMetadata ( null , OnTooltipTextChanged ) ) ;
1584
1584
1585
1585
/// <summary>
1586
- /// Called when [tooltip text changed] .
1586
+ /// Handles the <see cref="TooltipTextProperty" /> change .
1587
1587
/// </summary>
1588
- private void OnTooltipTextChanged ( )
1588
+ /// <param name="d">dependency object.</param>
1589
+ /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing property change data.</param>
1590
+ private static void OnTooltipTextChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
1591
+ {
1592
+ var owner = ( ChromiumWebBrowser ) d ;
1593
+ var oldValue = ( string ) e . OldValue ;
1594
+ var newValue = ( string ) e . NewValue ;
1595
+
1596
+ owner . OnTooltipTextChanged ( oldValue , newValue ) ;
1597
+ }
1598
+
1599
+ /// <summary>
1600
+ /// Called when tooltip text was changed changed.
1601
+ /// </summary>
1602
+ /// <param name="oldValue">old value</param>
1603
+ /// <param name="newValue">new value</param>
1604
+ protected virtual void OnTooltipTextChanged ( string oldValue , string newValue )
1589
1605
{
1590
1606
var timer = tooltipTimer ;
1591
1607
if ( timer == null )
1592
1608
{
1593
1609
return ;
1594
1610
}
1595
1611
1596
- if ( string . IsNullOrEmpty ( TooltipText ) )
1612
+ if ( string . IsNullOrEmpty ( newValue ) )
1597
1613
{
1598
- UiThreadRunAsync ( ( ) => UpdateTooltip ( null ) , DispatcherPriority . Render ) ;
1614
+ UiThreadRunAsync ( ( ) => OpenOrCloseToolTip ( null ) , DispatcherPriority . Render ) ;
1599
1615
1600
1616
if ( timer . IsEnabled )
1601
1617
{
@@ -2103,7 +2119,7 @@ private void OnTooltipTimerTick(object sender, EventArgs e)
2103
2119
{
2104
2120
tooltipTimer . Stop ( ) ;
2105
2121
2106
- UpdateTooltip ( TooltipText ) ;
2122
+ OpenOrCloseToolTip ( TooltipText ) ;
2107
2123
}
2108
2124
}
2109
2125
@@ -2122,12 +2138,12 @@ private void OnTooltipClosed(object sender, RoutedEventArgs e)
2122
2138
}
2123
2139
2124
2140
/// <summary>
2125
- /// Updates the tooltip.
2141
+ /// Open or Close the tooltip at the current mouse position .
2126
2142
/// </summary>
2127
- /// <param name="text">The text.</param>
2128
- private void UpdateTooltip ( string text )
2143
+ /// <param name="text">ToolTip text, if null or empty tooltip will be closed .</param>
2144
+ protected virtual void OpenOrCloseToolTip ( string text )
2129
2145
{
2130
- if ( String . IsNullOrEmpty ( text ) )
2146
+ if ( string . IsNullOrEmpty ( text ) )
2131
2147
{
2132
2148
toolTip . IsOpen = false ;
2133
2149
}
0 commit comments