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

How to bind tooltip to RadTreeViewItem

4 Answers 250 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mickaël
Top achievements
Rank 1
Mickaël asked on 19 Sep 2011, 01:50 PM
Hello,

I've been using RadTreeView control and am very pleased about it so far.
Yet I have an issue I couldn't solve myself : I'm binding a collection to the "ItemsSource" property of the RadTreeView.
I'd like one of the properties of the objects I'm binding to be the tooltip of the RadTreeViewItem (or the row if you speak "visually") and couldn't find a way to do it...

Can you help me ?
I hope I was clear. If not, don't hesitate to ask for further information.

Thanks in advance.
Sincerely,
Mickaël Derriey

4 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 22 Sep 2011, 11:53 AM
Hello Mickaël,

 You can set the Tooltip in the DataTemplate that you use in the TreeVIew like so:

<DataTemplate x:Key="itemteplate">
                <TextBlock Text="{Binding Name}">
                    <ToolTipService.ToolTip>
                        <ToolTip>
                            <ToolTip.Content>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Tooltip " />
                                    <TextBlock Text="{Binding Id}" />
                                </StackPanel>
                            </ToolTip.Content>
                        </ToolTip>
                    </ToolTipService.ToolTip>
                </TextBlock>
            </DataTemplate>
It is also important to set HorizontalContentAlignment to Stretch so that the tooltip appears when you MouseOver the whole RadTreeViewItem, not only the TextBlock .
<Style TargetType="telerik:RadTreeViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            </Style>

Hope this helps you.

Greetings,
Petar Mladenov
the Telerik team

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

0
Shirly
Top achievements
Rank 2
answered on 22 Apr 2013, 06:03 AM
Hi,
In case TreeViewItem row include more then one element of text , still th tooltip won't show if mouse is not on text control that includes the tooltip:
<DataTemplate x:Key="itemteplate">
               <Grid x:Name="grid" Height="30">
                   <Grid.ColumnDefinitions>
                       <ColumnDefinition Width="*"/>
                       <ColumnDefinition Width="400"/>
                   </Grid.ColumnDefinitions>
                     
                   <TextBlock Grid.Column="0" Text="{Binding Name}">
                       <ToolTipService.ToolTip>
                           <ToolTip>
                               <ToolTip.Content>
                                   <StackPanel Orientation="Horizontal">
                                       <TextBlock Text="Tooltip " />
                                       <TextBlock Text="{Binding Id}" />
                                   </StackPanel>
                               </ToolTip.Content>
                           </ToolTip>
                       </ToolTipService.ToolTip>
                   </TextBlock>
                   <TextBlock  Grid.Column="1" Text="This is more text.."/>
               </Grid>
           </DataTemplate>

Do you have any suggestion what to do in such case?

Thanks,
Shirly.
0
Tina Stancheva
Telerik team
answered on 24 Apr 2013, 08:41 AM
Hi Shirly,

I'm not sure I understand what you need to implement. But if you need to display a Tooltip on the entire RadTreeViewItem, then it might be better to apply the ToolTip on each RadTreeViewItem through a Style setter like this:
<Style TargetType="telerik:RadTreeViewItem">
    <Setter Property="ToolTipService.ToolTip">
        <Setter.Value>
            <ToolTip>
                <ToolTip.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Tooltip " />
                        <TextBlock Text="{Binding Id}" />
                    </StackPanel>
                </ToolTip.Content>
            </ToolTip>
        </Setter.Value>
    </Setter>
</Style>

Please give this a try and let me know if this is what you had in mind.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Shirly
Top achievements
Rank 2
answered on 24 Apr 2013, 12:14 PM
Thanks. It worked for me!
Tags
TreeView
Asked by
Mickaël
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Shirly
Top achievements
Rank 2
Tina Stancheva
Telerik team
Share this question
or