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

[Solved] Adding tooltips to a gridview

6 Answers 329 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Andrew asked on 20 Oct 2010, 05:26 PM
I found this in your documentation.
void gridView_RowLoaded(object sender, RowLoadedEventArgs e)
{
  var row = e.Row as GridViewRow;
  if (row != null)
  {
     ToolTip toolTip = new ToolTip()
     {
         Content = row.DataContext,
         ContentTemplate = (DataTemplate) this.LayoutRoot.Resources["MyToolTip"]
     };
     ToolTipService.SetToolTip(row, toolTip);
  }
}
http://www.telerik.com/help/silverlight/gridview-how-to-create-row-tooltip.html
Why is this necessary.  Setting tooltips on or off should be a xaml setting on the grid itself or on individual columns.  This just looks like a workaround to overcome a hole in the xaml options.  Would like the tooltip to be either set to instructions (fixed) or the data in the cell (for overflow) and I should be able to do that in XAML.

I am also not happy that I have to define childrows in c# instead of xaml.  Seems like a strange thing to leave out.

6 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Oct 2010, 07:48 AM
Hi Andrew,

You may define a ToolTip for the rows as follows:

<UserControl.Resources>    
        <Style TargetType="telerik:GridViewRow">
        <Setter Property="ToolTipService.ToolTip" Value="MyToolTipText" />
    </Style>       
</UserControl.Resources>

Furthermore, you may take a look at this blog post demonstrating another possible approach for adding a ToolTip for a row. Here, the information is actually the RowDetails for the current row.
In case this does not meet your requirements, please give us more details so that we are able to be more helpful and cover exactly your scenario.
As for your second concern, I am quite aware of what you mean by defining child-rows in the code-behind. What are exactly are you referring to?
 

Sincerely yours,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 21 Oct 2010, 11:59 AM
But what if you want the tooptip to be the contents of the cell for some cells, and column specific help for others?
0
Maya
Telerik team
answered on 21 Oct 2010, 04:04 PM
Hello Andrew,

You can easily set a ToolTip displaying the value of the corresponding cell as follows:

<StyleTargetType="{x:Type telerik:GridViewCell}">
        <SetterProperty="ToolTip"Value="{Binding            
                            Value,RelativeSource={RelativeSource Mode=Self}}"
/>
</Style>

Furthermore, you may take a look at our demo that demonstrates how to add a ToolTip for a particular column and even apply selector for its template.
 

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris
Top achievements
Rank 1
answered on 22 Dec 2010, 11:20 AM
Hi,

The code you have detailed is for WPF. Is there a Silverlight equivalent that will allow you to simply set a default tooltip for all cells in an auto generated grid to the contents of each cell?

Thanx,
Chris
0
Maya
Telerik team
answered on 27 Dec 2010, 03:44 PM
Hello Andrew,

The same scenario for Silverlight can be accomplished with a bit more code. You may either define the Tooltip for each column:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Name}" ToolTipService.ToolTip="{Binding Name}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Or handle the RowLoaded event as follows:
void playersGrid_RowLoaded(object sender, RowLoadedEventArgs e)
{
    var row = e.Row as GridViewRow;
    var cells = row.ChildrenOfType<GridViewCell>();
    foreach (GridViewCell cell in cells)
    {
        cell.SetValue(ToolTipService.ToolTipProperty, (cell.Column as GridViewDataColumn).DataMemberBinding.Path.Path);
    }          
}

 

Best wishes,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Selvakumar Savarimuthu
Top achievements
Rank 1
answered on 28 Dec 2010, 07:23 AM
Hi Team,

    Can we achieve like this in silverlight

        
<StyleTargetType="{x:Type telerik:GridViewCell}">
        <SetterProperty="ToolTip"Value="{Binding            
                            Value,RelativeSource={RelativeSource Mode=Self}}"
/>
</Style>

If now how can i without additional templates or code behind.
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Maya
Telerik team
Andrew
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Selvakumar Savarimuthu
Top achievements
Rank 1
Share this question
or