Close timer on all other tooltips on OnDataContextChanged

Topics: fixed
Mar 23, 2011 at 9:46 AM

Hi,

Thanks for producing this useful control.  Just to let you know I had to fix a minor issue with it - when the controls hosting the tooltips changed due to data binding update one of the tooltip timers was left running causing the ontick event to fire constantly.  As the tooltip CurrentTick value from this running timer was higher than the delay time this caused the tooltips to appear instantly and also meant that they didn't close properly on mouse leaving the element.

To correct this I just added the following within the OnDataContextChanged event handler in ToolTipService.cs:

if( kvp.Value.Timer != null )
{
	kvp.Value.Timer.StopAndReset();
}

That sorted it out.

Also noticed on Tooltip.cs method SetToolTipTimer line 114 and 115 the timer local variable is referenced where it should be the Timer property (capital 'T').

Have to say that attaching the dataContextProperty is pretty cunning, wouldn't have thought of that one! Until I spotted that I was going to hook up the FrameworkElement.Unloaded event (Silverlight 4 only) to ensure tooltips closed when the parent element is unloaded.