Exception when resizing root window

Topics: question
Feb 17, 2011 at 9:04 AM

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

 

PerformPlacement Line: 

var toolTip = GetTranslatedPoints((FrameworkElement)parentPopup.Child);

GetTranslatedPoints Line:

var generalTransform = frameworkElement.TransformToVisual(null);

It only happens when a pop has been open but is closed again, and I then resize the window.

Feb 17, 2011 at 10:50 AM
Hi,

thanks for reporting!

I'll look into it asap.
Cheers,
Xavier

2011/2/17 svrist <notifications@codeplex.com>

From: svrist

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

PerformPlacement Line:

var toolTip = GetTranslatedPoints((FrameworkElement)parentPopup.Child);

GetTranslatedPoints Line:

var generalTransform = frameworkElement.TransformToVisual(null);

It only happens when a pop has been open but is closed again, and I then resize the window.

Read the full discussion online.

To add a post to this discussion, reply to this email (tooltipservice@discussions.codeplex.com)

To start a new discussion for this project, email tooltipservice@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Feb 17, 2011 at 11:05 AM

My googling seems to suggest that it might be connected with the fact that the tooltip is not visible when the TransformToVisual is called.

Feb 20, 2011 at 11:41 AM
Hi,

so far, I haven't been able to reproduce the issue.
Could you please send me some sample app that reproduces the defect?

Thanks!
Best regards,
Xavier

2011/2/17 svrist <notifications@codeplex.com>

From: svrist

My googling seems to suggest that it might be connected with the fact that the tooltip is not visible when the TransformToVisual is called.

Read the full discussion online.

To add a post to this discussion, reply to this email (tooltipservice@discussions.codeplex.com)

To start a new discussion for this project, email tooltipservice@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Feb 21, 2011 at 8:20 AM

A xaml with a

<Rectangle Width="100" Height="100" Fill="Aqua" x:Name="rect"></Rectangle>

 

I havent found a way to set PLacementTarget in xaml so I use a loaded method like this:

void rect_Loaded(object sender, RoutedEventArgs e)
{
        var tt = new ToolTip()
                     {
                         PlacementTarget = rect,
                         Placement = PlacementMode.Right,
                         Content = "tooltip text",
                     };
        ToolTipService.SetToolTip(rect,tt);
}

After you load the application it is easy to get to see the tooltip. No problem. If you then, after seeing the tooltip, resize the screen OR change zoomlevel the exception occours

On a side note it seems like if you use a browser with !100% zoomlevel the placement is wrong as well?

Tooltip image - Zoom
Feb 21, 2011 at 8:25 AM

As a Diff to your demo application:

 

Index: Dev/Silverlight.Controls.ToolTips.Demo/Views/Home.xaml
===================================================================
--- Dev/Silverlight.Controls.ToolTips.Demo/Views/Home.xaml	(revision 58224)
+++ Dev/Silverlight.Controls.ToolTips.Demo/Views/Home.xaml	(working copy)
@@ -26,6 +26,7 @@
     <Grid>
         <ScrollViewer Style="{StaticResource PageScrollViewerStyle}">
             <StackPanel>
+                <Rectangle Width="100" Height="100" Fill="Aqua" x:Name="rect"></Rectangle>
                 <TextBlock Style="{StaticResource HeaderTextStyle}"
                            Text="Home" />
                 <TextBlock Style="{StaticResource ContentTextStyle}"
Index: Dev/Silverlight.Controls.ToolTips.Demo/Views/Home.xaml.cs
===================================================================
--- Dev/Silverlight.Controls.ToolTips.Demo/Views/Home.xaml.cs	(revision 58224)
+++ Dev/Silverlight.Controls.ToolTips.Demo/Views/Home.xaml.cs	(working copy)
@@ -1,5 +1,7 @@
 &#65279;using System;
 using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Input;
 using System.Windows.Threading;
 
@@ -34,8 +36,20 @@
             displayTimeTimer.Tick += OnDisplayTimerTick;
             openAnimationTimer.Tick += OnOpenAnimationTimerTick;
             closeAnimationTimer.Tick += OnCloseAnimationTimerTick;
+            rect.Loaded += new RoutedEventHandler(rect_Loaded);
         }
 
+        void rect_Loaded(object sender, RoutedEventArgs e)
+        {
+            var tt = new ToolTip()
+                         {
+                             PlacementTarget = rect,
+                             Placement = PlacementMode.Right,
+                             Content = "tooltip text",
+                         };
+            ToolTipService.SetToolTip(rect,tt);
+        }
+
         private void OnButtonIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
         {
             if (!(bool)e.NewValue)

Feb 24, 2011 at 4:58 PM

This quick hack solves the problem for me:

Index: Dev/Silverlight.Controls.ToolTips/ToolTipService.cs
===================================================================
--- Dev/Silverlight.Controls.ToolTips/ToolTipService.cs	(revision 58377)
+++ Dev/Silverlight.Controls.ToolTips/ToolTipService.cs	(working copy)
@@ -431,7 +431,7 @@
         private static Point[] GetTranslatedPoints(FrameworkElement frameworkElement)
         {
             var pointArray = new Point[4];
-            if (frameworkElement != null)
+            if (frameworkElement != null && (frameworkElement is ToolTip ? ((ToolTip)frameworkElement).IsOpen : true))
             {
                 var generalTransform = frameworkElement.TransformToVisual(null);
                 pointArray[0] = generalTransform.Transform(new Point(0.0, 0.0));

Feb 24, 2011 at 7:21 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 24, 2011 at 7:28 PM
Hi,

thank you, that indeed seems to work.
I've applied your fix to the sources.

Cheers,
Xavier

2011/2/24 svrist <notifications@codeplex.com>

From: svrist

This quick hack solves the problem for me:

Index: Dev/Silverlight.Controls.ToolTips/ToolTipService.cs
===================================================================
--- Dev/Silverlight.Controls.ToolTips/ToolTipService.cs	(revision 58377)
+++ Dev/Silverlight.Controls.ToolTips/ToolTipService.cs	(working copy)
@@ -431,7 +431,7 @@
         private static Point[] GetTranslatedPoints(FrameworkElement frameworkElement)
         {
             var pointArray = new Point[4];
-            if (frameworkElement != null)
+            if (frameworkElement != null && (frameworkElement is ToolTip ? ((ToolTip)frameworkElement).IsOpen : true))
             {
                 var generalTransform = frameworkElement.TransformToVisual(null);
                 pointArray[0] = generalTransform.Transform(new Point(0.0, 0.0));

Read the full discussion online.

To add a post to this discussion, reply to this email (tooltipservice@discussions.codeplex.com)

To start a new discussion for this project, email tooltipservice@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Feb 24, 2011 at 8:58 PM

I dont know about the placement issue when using browser zoom though :|

Feb 24, 2011 at 9:40 PM
I'll look into it further ;-)

2011/2/24 svrist <notifications@codeplex.com>

From: svrist

I dont know about the placement issue when using browser zoom though :|

Read the full discussion online.

To add a post to this discussion, reply to this email (tooltipservice@discussions.codeplex.com)

To start a new discussion for this project, email tooltipservice@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 7, 2011 at 8:01 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 7, 2011 at 8:04 PM
The issue has been resolved in the latest sources (yet to be released).
It seems the Silverlight runtime has fixed the mouseposition coordinates issue when browser zoom factor was used, so I could remove my custom code that was correcting this behavior.
Kr,
Xavier

2011/2/24 svrist <notifications@codeplex.com>

From: svrist

I dont know about the placement issue when using browser zoom though :|

Read the full discussion online.

To add a post to this discussion, reply to this email (tooltipservice@discussions.codeplex.com)

To start a new discussion for this project, email tooltipservice@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Nov 20, 2011 at 12:16 PM

I encountered the same issue in a navigation application. Please see the description at http://tooltipservice.codeplex.com/discussions/280147

Mar 13, 2014 at 10:50 AM