Tooltip exception when out of the visible area

4 posts, 0 answers
  1. Doug
    Doug avatar
    49 posts
    Member since:
    May 2012

    Posted 27 Jul 2012 Link to this post

    We are using this in bing map to open it when we click on a pushpin, and in most cases when it would open outside the visible area of the screen we get the following exception:


     at Telerik.Windows.Controls.RadToolTip.SetPosition(Size toolTipSize)
       at Telerik.Windows.Controls.RadToolTip.<.ctor>b__0()
       at Telerik.Windows.Controls.RadWindow.CanvasLayoutUpdated(Object sender, EventArgs e)
       at System.Windows.FrameworkElement.OnLayoutUpdated(Object sender, EventArgs e)
       at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)

    Implementation:
    <Style TargetType="telerikPrimitives:RadToolTip" x:Key="ToolTipStyle">
                <Setter Property="Foreground" Value="White"/>
                <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
                <Setter Property="OpenAnimation">
                    <Setter.Value>
                        <telerikCore:RadScaleYAnimation StartScaleY="0" EndScaleY="1" AnimationOrigin="0.5, 1" FillBehavior="Stop" Duration="0:0:0.3">
                            <telerikCore:RadScaleYAnimation.Easing>
                                <QuadraticEase/>
                            </telerikCore:RadScaleYAnimation.Easing>
                        </telerikCore:RadScaleYAnimation>
                    </Setter.Value>
                </Setter>
                <Setter Property="CloseAnimation">
                    <Setter.Value>
                        <telerikCore:RadFadeAnimation StartOpacity="1" EndOpacity="0" FillBehavior="Stop"/>
                    </Setter.Value>
                </Setter>
            </Style>

    Bing Map Datatemplate:
    <DataTemplates:MapPinSelector.PinTemplate>
                                                            <DataTemplate>
                                                                <Grid x:Name="ContentGrid" telerikPrimitives:RadToolTipService.ShowGesture="Tap"
                                                                                           telerikPrimitives:RadToolTipService.ToolTip="{Binding}"
                                                                                           telerikPrimitives:RadToolTipService.Style="{StaticResource ToolTipStyle}"
                                                                                           telerikPrimitives:RadToolTipService.Template="{StaticResource TooltipTemplate}">


                                                                    <ContentPresenter HorizontalAlignment="Center" Margin="1,85,1,0">
                                                                        <ContentPresenter.Content>
                                                                            <Canvas RenderTransformOrigin="0.5,1.0">
                                                                                <Path Data="M5.0000005,0 L69,0 C71.761421,0 74,2.2385762 74,5.0000005 L74,69 C74,71.761421 71.761421,74 69,74 L47.606602,74 L37,84.606598 L26.393398,74 L5.0000005,74 C2.2385767,74 5.5252349E-07,71.761421 0,69 L0,5.0000005 C5.5252349E-07,2.2385762 2.2385767,0 5.0000005,0 z" Margin="0,0,0,0" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" Fill="{Binding StatusColor,Converter={StaticResource ColorToSolidColorBrushConverter}}">
                                                                                    <Path.RenderTransform>
                                                                                        <CompositeTransform TranslateX="-37" TranslateY= "-85"/>
                                                                                    </Path.RenderTransform>
                                                                                </Path>
                                                                                <Image x:Name="avatar" Margin="5,5,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Height="64" Width="64" Source="{Binding Avatar}">
                                                                                    <Image.RenderTransform>
                                                                                        <CompositeTransform TranslateX="-37" TranslateY="-85" />
                                                                                    </Image.RenderTransform>
                                                                                </Image>
                                                                            </Canvas>
                                                                        </ContentPresenter.Content>
                                                                    </ContentPresenter>
                                                                </Grid>
                                                            </DataTemplate>
                                                        </DataTemplates:MapPinSelector.PinTemplate>

    Thanks in advance Best Regards 
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 01 Aug 2012 Link to this post

    Hello Doug,

    Thanks for writing.
    I am afraid that just the XAML and stack trace do not give enough information about the exception. Please specify the exact steps to reproduce the issue and what the type of the exception is. We will be able to resolve this issue as quickly as possible if you send a sample application that demonstrates it, if this is possible of course.
    I am looking forward to your reply.

    Kind regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Doug
    Doug avatar
    49 posts
    Member since:
    May 2012

    Posted 01 Aug 2012 Link to this post

    It is a nullrefference exception, and it is happening possibly because as we are opening the tooltip, the map is zooming, but I cannot really give you a specific way to reproduce it, because it is happening randomly. I'm sorry I can't provide more information...
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 06 Aug 2012 Link to this post

    Hello Doug,

    Thanks for writing again.
    After examining the SetPosition() method it turns out there is only one place where it can crash with a null reference exception.

    private void SetPosition(Size toolTipSize)
    {
        if (this.pointer != null)
        {
            this.pointer.Opacity = 1;
        }
     
        UIElement parent = this.Parent as UIElement;
        this.page = ElementTreeHelper.FindVisualAncestor<PhoneApplicationPage>(this.RelativeElement);
     
        // Calculate position relative to the tooltip owner.
        this.CalculatePosition(parent, this.page.RenderSize, toolTipSize);
    }

    Notice how the parent variable cannot be the cause since it is never dereferenced. ElementTreeHelper also can't be the cause since it is a static class. Also it does not crash inside FindVisualAncestor() because the stack trace you posted ends with the SetPosition() method. With that said, the only possible place for a null reference exception to occur is when the page's RenderSize is accessed. This means that ElementTreeHelper returned null because no page exists in the Silverlight element tree at this moment.

    Please clarify at which point of your application's life-cycle  does the exception occur. You can try opening the tooltip when you are sure your application has created the current page. We will see what we can do on our side in order to prevent this exception.

    Thanks for the feedback. Your Telerik points have been updated for this bug report.

    Greetings,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top