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

ToolTipTemplate

2 Answers 338 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 07 May 2012, 08:58 PM
I have this defined to let each cell display it's value in a tooltip:
<Style TargetType="telerik:GridViewCell">
   <Setter Property="ToolTip" Value="{Binding Value,RelativeSource={RelativeSource Mode=Self}}" />
</Style>

It works, but for cells that have lots of content, it doesn't wrap the text. So I defined this ToolTipTemplate for the column that has lots of text:

<DataTemplate x:Key="GridViewToolTipTemplate">
   <TextBlock Text="{Binding Description, Converter={StaticResource LineBreaksConverter}}" TextWrapping="Wrap" MaxWidth="400" />
</DataTemplate>

The DataMemberBinding has the same expression as the Text of the Textblock, this just allows the text to wrap. It works well, but...

I'd like to reuse this template for another column, rather than having to define this template again. I'm just not sure what to bind the Text property to so that it works for whatever column I use it with.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 08 May 2012, 09:29 AM
Hi,

You would better define a style that targets the 'ToolTip' type.

<Style TargetType="ToolTip">
              <Setter Property="ContentTemplate">
                  <Setter.Value>
                      <DataTemplate>
                          <StackPanel>
                              <TextBlock Text="{Binding}"
                       TextWrapping='Wrap' />
                          </StackPanel>
                      </DataTemplate>
                  </Setter.Value>
              </Setter>
</Style>

That way the text on all the ToolTips will be wrapped.

Kind regards,
Didie
the Telerik team

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

Dhruba
Top achievements
Rank 1
commented on 30 Sep 2021, 06:34 AM

Hi!

I was trying to apply the same style with RadGridView cell tooltip but didn't work.

 

Could you please help in this regard?

 

Kind regards,

Dhruba

Stenly
Telerik team
commented on 04 Oct 2021, 02:27 PM

I have prepared a sample project, that might be a possible solution for your question. The style is the same as the one code snippet provided by my colleague, so could you give this project a try? 
0
Rayne
Top achievements
Rank 1
answered on 08 May 2012, 01:42 PM
Thanks. I didn't think of changing the content template.
Tags
GridView
Asked by
Rayne
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or