This is a migrated thread and some comments may be shown as answers.

Binding problem in ToolTip

3 Answers 142 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ellic
Top achievements
Rank 1
ellic asked on 26 Apr 2012, 09:48 AM
I'm using ToolTip Control in the RadDataBoundListBox, and the Itemtemplate is as followed:
<telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="6" Height="150" HorizontalAlignment="Left"
                              telerikPrimitives:RadToolTipService.Style="{StaticResource HubStyle}"
                               telerikPrimitives:RadToolTipService.ShowGesture="Tap">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="90"/>
                                <RowDefinition Height="40"/>
                            </Grid.RowDefinitions>
                              <telerikPrimitives:RadToolTipService.ToolTip>
                                <StackPanel Width="230" Margin="3, 0, 0, 0">
                                    <TextBlock TextWrapping="Wrap" FontSize="23" Text="{Binding Path=screen_name}">
                                    </TextBlock>
                                    <TextBlock TextWrapping="Wrap" FontSize="23">
                                            Gender: <Run Text="{Binding gender}"/>
                                    </TextBlock>
                                    <TextBlock TextWrapping="Wrap" FontSize="23">
                                            Location: <Run Text="{Binding Path=location}"/>
                                    </TextBlock>
                                </StackPanel>
                            </telerikPrimitives:RadToolTipService.ToolTip>
                            <Image Height="90" Width="90" Source="{Binding profile_image_url_large}">
                                <Image.Clip>
                                    <RectangleGeometry Rect="0,0,90,90" RadiusX="3" RadiusY="3"/>
                                </Image.Clip>
                            </Image>
                            <TextBlock Text="{Binding screen_name,Converter={StaticResource RecommandNameConverter},Mode=OneWay}"
                                       Width="90" Grid.Row="1" Margin="0,3" Foreground="{StaticResource Fanfou_Foreground}"/>
                        </Grid>
                    </DataTemplate>
                </telerikPrimitives:RadDataBoundListBox.ItemTemplate>

The problem is that the Binding didn't work. It's supposed that when the user tap the Grid, a ToolTip, containing the Name, Gender and Location info, will pop up.  But it didn't perform correctly.

The Image and the last TextBolck work well, so it's not the Binding's fault.

3 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 26 Apr 2012, 03:57 PM
Hi Ellic,

Thank you for writing.

There is a little quirk with the tool tip that you should be aware of. Since RadToolTip uses RadWindow to show itself above everything else, the data context of the tool tip is not same as the data context of your list box item template. The reason for this is the following: RadWindow, when opened, inserts a panel in the page's LayoutRoot. Then it puts its content (a RadToolTip instance in this case) inside this panel. Therefore, even though you declare your tool tip inside the item template, during run-time it ends up inserted inside the layout root, which is outside the item template.

The remedy is very simple. For example, you can name your grid (the one that is inside your list box item template) to something. Then, bind the DataContext property of the stack panel in the tool tip to the grid's DataContext.
This will be fixed in the next Q2 2012 release.

Please write again if you have other questions.

Regards,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
ellic
Top achievements
Rank 1
answered on 27 Apr 2012, 07:28 AM
Thanks for your reply, do you mean changing the code into
<telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="6" Height="150" HorizontalAlignment="Left"
                              telerikPrimitives:RadToolTipService.Style="{StaticResource HubStyle}"
                               telerikPrimitives:RadToolTipService.ShowGesture="Tap" x:Name="InerGrid">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="90"/>
                                <RowDefinition Height="40"/>
                            </Grid.RowDefinitions>
                              <telerikPrimitives:RadToolTipService.ToolTip>
                                <StackPanel Width="230" Margin="3, 0, 0, 0" DataContext="{Binding DataContext,ElementName=InerGrid}">
                                    <TextBlock TextWrapping="Wrap" FontSize="23" Text="{Binding Path=screen_name}">
                                    </TextBlock>
                                    <TextBlock TextWrapping="Wrap" FontSize="23">
                                            Gender: <Run Text="{Binding gender}"/>
                                    </TextBlock>
                                    <TextBlock TextWrapping="Wrap" FontSize="23">
                                            Location: <Run Text="{Binding Path=location}"/>
                                    </TextBlock>
                                </StackPanel>
                            </telerikPrimitives:RadToolTipService.ToolTip>
                            <Image Height="90" Width="90" Source="{Binding profile_image_url_large}">
                                <Image.Clip>
                                    <RectangleGeometry Rect="0,0,90,90" RadiusX="3" RadiusY="3"/>
                                </Image.Clip>
                            </Image>
                            <TextBlock Text="{Binding screen_name,Converter={StaticResource RecommandNameConverter},Mode=OneWay}"
                                       Width="90" Grid.Row="1" Margin="0,3" Foreground="{StaticResource Fanfou_Foreground}"/>
                        </Grid>
                    </DataTemplate>
                </telerikPrimitives:RadDataBoundListBox.ItemTemplate>

But it still doesn't work.
0
Victor
Telerik team
answered on 02 May 2012, 09:02 AM
Hi ellic,

Thanks for writing.
Please download the latest internal build, it contains a fix for the tool tip that should address this issue.
Write again if you need further assistance, we're ready to assist you.

Greetings,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ToolTip
Asked by
ellic
Top achievements
Rank 1
Answers by
Victor
Telerik team
ellic
Top achievements
Rank 1
Share this question
or