@@ -1580,22 +1580,38 @@ public string TooltipText
15801580 /// The tooltip text property
15811581 /// </summary>
15821582 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 ) ) ;
15841584
15851585 /// <summary>
1586- /// Called when [tooltip text changed] .
1586+ /// Handles the <see cref="TooltipTextProperty" /> change .
15871587 /// </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 )
15891605 {
15901606 var timer = tooltipTimer ;
15911607 if ( timer == null )
15921608 {
15931609 return ;
15941610 }
15951611
1596- if ( string . IsNullOrEmpty ( TooltipText ) )
1612+ if ( string . IsNullOrEmpty ( newValue ) )
15971613 {
1598- UiThreadRunAsync ( ( ) => UpdateTooltip ( null ) , DispatcherPriority . Render ) ;
1614+ UiThreadRunAsync ( ( ) => OpenOrCloseToolTip ( null ) , DispatcherPriority . Render ) ;
15991615
16001616 if ( timer . IsEnabled )
16011617 {
@@ -2103,7 +2119,7 @@ private void OnTooltipTimerTick(object sender, EventArgs e)
21032119 {
21042120 tooltipTimer . Stop ( ) ;
21052121
2106- UpdateTooltip ( TooltipText ) ;
2122+ OpenOrCloseToolTip ( TooltipText ) ;
21072123 }
21082124 }
21092125
@@ -2122,12 +2138,12 @@ private void OnTooltipClosed(object sender, RoutedEventArgs e)
21222138 }
21232139
21242140 /// <summary>
2125- /// Updates the tooltip.
2141+ /// Open or Close the tooltip at the current mouse position .
21262142 /// </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 )
21292145 {
2130- if ( String . IsNullOrEmpty ( text ) )
2146+ if ( string . IsNullOrEmpty ( text ) )
21312147 {
21322148 toolTip . IsOpen = false ;
21332149 }
0 commit comments