Exception when resizing root window in navigation application

Nov 20, 2011 at 12:14 PM

I encountered an issue described at "Exception when resizing root window" (http://tooltipservice.codeplex.com/discussions/246428) in a naviration application.

I have a standard Silverlight navigation application. Page1 uses the Advanced ToolTip to display some information for an UI element on the page. After ToolTip was displayed (it is important), I can resize the browser window without any issue. Then I navigate to a Page2 that does not have any Advanced ToolTip controls. Resize of the browser window causes the following exception:

System.ArgumentException was unhandled by user code
  Message=Value does not fall within the expected range.
       v MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
       v MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
       v MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)
       v System.Windows.UIElement.TransformToVisual(UIElement visual)
       v Silverlight.Controls.ToolTips.ToolTipService.GetTranslatedPoints(FrameworkElement frameworkElement)
       v Silverlight.Controls.ToolTips.ToolTipService.PerformPlacement(Double horizontalOffset, Double verticalOffset)
       v Silverlight.Controls.ToolTips.ToolTipService.OnRootVisualSizeChanged(Object sender, SizeChangedEventArgs e)
       v System.Windows.SizeChangedEventHandler.Invoke(Object sender, SizeChangedEventArgs e)
       v System.Windows.FrameworkElement.OnSizeChanged(Object sender, SizeChangedEventArgs e)
       v MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)

Under the debugger I can see where it exactly fails (code based on the change set #63304):

// in ToolTipService::GetTranslatedPoints method, line 437
var generalTransform = frameworkElement.TransformToVisual(null);

// in ToolTipService::PerformPlacement method, line 416
var translatedPoints = GetTranslatedPoints((FrameworkElement)placementTarget);

// in ToolTipService::OnRootVisualSizeChanged method, line 289
PerformPlacement(CurrentToolTip.HorizontalOffset, CurrentToolTip.VerticalOffset);

Please consider a workaround for this issue: to check whether a popup is open at the beginning of the PerformPlacement method. The code looks like this:

private static void PerformPlacement(double horizontalOffset, double verticalOffset)
     if (!CurrentToolTip.IsOpen)


I consider my workaround more like a hack. It would be nice to see a better solution.

Mar 13, 2014 at 10:52 AM