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

GridViewDataColumn Tooltip

15 Answers 878 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rogério
Top achievements
Rank 1
Rogério asked on 13 Mar 2009, 04:20 PM
Hello,

I'm trying to define a GridViewColumn Tooltip, but without any success so far! I already tried to use ToolTipService.Tooltip to specify a TextBlock by code, but nothing is displayed!

Any suggestion?

Thanks.

Regards,
Rogério

15 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Mar 2009, 03:55 PM
Hello Rogério,

If you want tooltip for every cell in specific column you can use the approach from this demo:

 <Controls:GridViewColumn Width="*"  HeaderText="Product Logo (Unbound)">
                    <Controls:GridViewColumn.CellStyle>
                        <Style TargetType="telerikGridView:GridViewCell">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="telerikGridView:GridViewCell">
                                        <Border ToolTipService.ToolTip="{Binding ImageUrl}" BorderThickness="{TemplateBinding BorderThickness}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            Background="{TemplateBinding Background}">
                                            <HyperlinkButton TargetName="_blank" NavigateUri="{Binding Url}">
                                                <Image Source="{Binding ImageUrl, Converter={StaticResource converter}}" />
                                            </HyperlinkButton>
                                        </Border>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Controls:GridViewColumn.CellStyle>
                </Controls:GridViewColumn>

Regards,
Vlad
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rogério
Top achievements
Rank 1
answered on 16 Mar 2009, 04:42 PM
Sorry, but I cannot see any ToolTip displayed on the sample that you suggested!!

I was talking about displaying a ToolTip, only, for the columns Header, not for the Cell.

Regards,
Rogério
0
Accepted
Pavel Pavlov
Telerik team
answered on 18 Mar 2009, 03:21 PM
Hello Rogério,


Here is some sample code to programmatically assign a tooltip text to the header cells.
I believe there is also a XAML based way but it would require to modify the 'fat" xaml template of the header cell. So I think the best solution for your scenario is something like:
public Page()  
        {  
            InitializeComponent();  
            this.TestGridView.RowLoaded += new EventHandler<RowLoadedEventArgs>(TestGridView_RowLoaded);  
              
        }  
 
        void TestGridView_RowLoaded(object sender, RowLoadedEventArgs e)  
        {  
            if(e.Row is GridViewHeaderRow)  
            {  
                GridViewHeaderRow headerRow = e.Row as GridViewHeaderRow;  
                foreach (GridViewHeaderCell cell in headerRow.Items)  
                {  
                    cell.SetValue(ToolTipService.ToolTipProperty,"test tooltip");  
                }  
            }  
        } 

I am aware this is a kind of Winforms approach but it will do the job. Meanwhile we are doing our best to provide easy and declarative way to achieve such tasks for our future releases.

Best wishes,
Pavel Pavlov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Celeste
Top achievements
Rank 1
answered on 28 Sep 2009, 03:23 PM
I would like to know if with last dlls for Silverlight 3, exists a better way to do this.

Thanks

Celeste.
0
Pavel Pavlov
Telerik team
answered on 29 Sep 2009, 02:32 PM
Hi Celeste,

We have added a Header property to the column. You may set the header to any visual you want . For example you may set the Header to a TextBlock to display the column name and set the desired  tooltip to this textblock .
Let me know if you find troubles implementing this.

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Celeste
Top achievements
Rank 1
answered on 29 Sep 2009, 04:20 PM
Thanks!
I' ve tried what you explain in the answer and it worked.

But I am having problem with gridviewcolumns that I am creating by code and adding to gridview, because throws an exception.

                
                while (condition)
                {
                column = 
new GridViewDataColumn();  
                TextBlock header_t = new TextBlock();  
                header_t.Text = col.TITLE;  
                ToolTipService.SetToolTip(header_t, "test MCM");  
                column.Header = header_t;  
                .....  
                gridview.Columns.Add(column);  
                }
 


It throws an exception in gridview.Columns.Add in the second iteration. If I comment:

                TextBlock header_t = new TextBlock();     
                header_t.Text = col.TITLE;     
                ToolTipService.SetToolTip(header_t, "test MCM");  
 
everythings works.


'The element is already the child of another element'...


System.Windows.Markup.XamlParseException was unhandled by user code 
  Message=" [Line: 0 Position: 0]\r\n   --- Inner Exception ---\r\nEl elemento ya es un objeto secundario de otro elemento.\r\n" 
  LineNumber=0  
  LinePosition=0  
  StackTrace:  
       en MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)  
       en MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)  
       en MS.Internal.XcpImports.FrameworkElement_ApplyTemplate(FrameworkElement frameworkElement)  
       en System.Windows.FrameworkElement.ApplyTemplateInternal()  
       en System.Windows.Controls.Control.ApplyTemplate()  
       en Telerik.Windows.Controls.GridView.GridViewDataControl.<PopulateHeaderAndFooterRows>b__45(GridViewCellBase c)  
       en System.Collections.Generic.List`1.ForEach(Action`1 action)  
       en Telerik.Windows.Controls.GridView.GridViewDataControl.PopulateHeaderAndFooterRows()  
       en Telerik.Windows.Controls.GridView.GridViewDataControl.OnColumnsCollectionChanged(NotifyCollectionChangedEventArgs e)  
       en Telerik.Windows.Controls.GridViewColumnCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)  
       en System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)  
       en Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)  
       en System.Collections.ObjectModel.Collection`1.Add(T item)  
       en Silverlight.Common.Page.ReorderAllColumns(RadGridView gridView, ObservableCollection`1 lista)  
       en Cupos.ABMSolEnt.<NewComprobante>b__0()  
  InnerException: System.InvalidOperationException  
       Message="El elemento ya es un objeto secundario de otro elemento." 
       StackTrace:  
            en MS.Internal.XcpImports.CheckHResult(UInt32 hr)  
            en MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)  
            en MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)  
            en System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)  
            en System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)  
            en System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)  
            en System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)  
            en System.Windows.Controls.ContentControl.set_Content(Object value)  
            en Telerik.Windows.Controls.GridView.GridViewHeaderCell.SetHeaderText()  
            en Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnApplyTemplate()  
            en System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)  
       InnerException:   
 







0
Pavel Pavlov
Telerik team
answered on 02 Oct 2009, 10:57 AM
Hi Celeste,

We had such known issue with headers. Can you please download the latest internal build and give it a try. I believe it has been fixed and switching to the newer dills should help here.

Greetings,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Celeste
Top achievements
Rank 1
answered on 05 Oct 2009, 02:24 PM
The issue was fixed!
Thanks.
0
Scott
Top achievements
Rank 1
answered on 08 Jul 2010, 12:34 AM
Hi Pavel,

I'm trying your approach to adding tooltips to GridViewDataColumn column header cells. I'm using  RadControls_for_Silverlight_4_2010_1_0422_TRIAL version of the controls. My problem is that GridViewHeaderRow.Cells returns only one GridViewHeaderCel despite the fact that I have 7 columns in the grid. The tooltip on the first column gets set as expected, but the remaining six columns are never processed by the foreach loop.

How can I set tooltips on the remaining column headings?

My XAML is:
                <telerikControls:RadGridView x:Name="permissionsGridView" 
                                             Grid.Row="1" 
                                             Background="{StaticResource DetailAreaBackgroundBrush}" 
                                             ShowGroupPanel="False" 
                                             ItemsSource="{Binding Mode=OneWay}" 
                                             AutoGenerateColumns="False" 
                                             IsReadOnly="{Binding Path=Current.User.CanUpdate, Mode=OneWay, Converter={StaticResource NotOperatorConverter}, Source={StaticResource WebContext}}" 
                                             CanUserFreezeColumns="False" 
                                             CanUserReorderColumns="False" 
                                             CanUserSortColumns="True" 
                                             CanUserInsertRows="False" 
                                             CanUserDeleteRows="False" 
                                         > 
                    <telerikControls:RadGridView.SortDescriptors> 
                        <telerikData:SortDescriptor Member="ModuleName" /> 
                    </telerikControls:RadGridView.SortDescriptors> 
                     
                    <telerikControls:RadGridView.Columns> 
                        <!-- Module Names--> 
                        <telerikControls:GridViewDataColumn Header="Module"  DataMemberBinding="{Binding Path=ModuleName, Mode=OneWay}" /> 
 
                        <!-- Permissions --> 
                        <telerikControls:GridViewDataColumn Header="Create" > 
                            <telerikControls:GridViewDataColumn.CellTemplate> 
                                <DataTemplate> 
                                    <CheckBox IsChecked="{Binding srmp_cancreate, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                </DataTemplate> 
                            </telerikControls:GridViewDataColumn.CellTemplate> 
                        </telerikControls:GridViewDataColumn> 
 
                        <telerikControls:GridViewDataColumn Header="Read"
                            <telerikControls:GridViewDataColumn.CellTemplate> 
                                <DataTemplate> 
                                    <CheckBox IsChecked="{Binding srmp_canread, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                </DataTemplate> 
                            </telerikControls:GridViewDataColumn.CellTemplate> 
                        </telerikControls:GridViewDataColumn> 
 
                        <telerikControls:GridViewDataColumn Header="Update" > 
                            <telerikControls:GridViewDataColumn.CellTemplate> 
                                <DataTemplate> 
                                    <CheckBox IsChecked="{Binding srmp_canupdate, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                </DataTemplate> 
                            </telerikControls:GridViewDataColumn.CellTemplate> 
                        </telerikControls:GridViewDataColumn> 
 
                        <telerikControls:GridViewDataColumn Header="Delete"
                            <telerikControls:GridViewDataColumn.CellTemplate> 
                                <DataTemplate> 
                                    <CheckBox IsChecked="{Binding srmp_candelete, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                </DataTemplate> 
                            </telerikControls:GridViewDataColumn.CellTemplate> 
                        </telerikControls:GridViewDataColumn> 
 
                        <telerikControls:GridViewDataColumn Header="Forward"
                            <telerikControls:GridViewDataColumn.CellTemplate> 
                                <DataTemplate> 
                                    <CheckBox IsChecked="{Binding srmp_canforward, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
                                </DataTemplate> 
                            </telerikControls:GridViewDataColumn.CellTemplate> 
                        </telerikControls:GridViewDataColumn> 
 
                        <telerikControls:GridViewDataColumn Header="See All"
                            <telerikControls:GridViewDataColumn.CellTemplate> 
                                <DataTemplate> 
                                    <CheckBox IsChecked="{Binding srmp_canseeall, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
                                </DataTemplate> 
                            </telerikControls:GridViewDataColumn.CellTemplate> 
                        </telerikControls:GridViewDataColumn> 
 
                    </telerikControls:RadGridView.Columns> 
 
                </telerikControls:RadGridView> 




Code behind is:
    public partial class SecurityRoleDetailView : ISecurityRoleDetailView 
    { 
        public SecurityRoleDetailView(ISecurityRoleDetailViewModel viewModel) 
        { 
            if (viewModel == null
            { 
                throw new ArgumentNullException("viewModel"); 
            } 
            InitializeComponent(); 
            DataContext = viewModel; 
            permissionsGridView.RowLoaded += PermissionsGridViewRowLoadedHandler; 
        } 
 
        private void PermissionsGridViewRowLoadedHandler(object sender, RowLoadedEventArgs e) 
        { 
            if (e.Row is GridViewHeaderRow) 
            { 
                GridViewHeaderRow headerRow = e.Row as GridViewHeaderRow; 
                foreach (GridViewHeaderCell headerCell in headerRow.Cells) 
                { 
                    headerCell.SetValue(ToolTipService.ToolTipProperty, "Test Tooltip"); 
                } 
            } 
        } 
    } 

What am I missing?
Thanks,
Scott


0
Vlad
Telerik team
answered on 08 Jul 2010, 08:16 AM
Hi,

 You can set EnableColumnVirtualization to false to avoid this.

Regards,
Vlad
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
Scott
Top achievements
Rank 1
answered on 08 Jul 2010, 11:02 PM
Hi Vlad,

Works perfectly--thanks for the outstanding support.

Scott.
0
Naseem
Top achievements
Rank 1
answered on 16 Nov 2010, 10:35 PM
Hi,

I'm using the latest version of RadControl and I need to set tooltip for GridViewColumn in a way the column bind to a feild and the tooltip bind to another feild .

by using silverlight datagrid ,here was how I implemeted it:

 

<data:DataGridTemplateColumn Header="Filter">
    <data:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Description}" ToolTipService.ToolTip="{Binding FilterHint}" Width="100" Margin="0,5"/>
        </DataTemplate>
    </data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>

 

 

In telerik ,I have tried this and it didn't work

 

 

<GridView:GridViewDataColumn Header="Filter" Width="230" DataMemberBinding="{Binding Description}"  IsReadOnly="True">
                    <GridView:GridViewDataColumn.ToolTipTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding FilterHint}" Width="100" Margin="0,5"/>
                            </StackPanel>
                        </DataTemplate>
                    </GridView:GridViewDataColumn.ToolTipTemplate>
</GridView:GridViewDataColumn>

 


Actually I have realized when both GridViewColumn and textBlock bind to one field ,it working . but I need it to bind them to different fileds.

I appreciate your help,

Thank you

0
Vlad
Telerik team
answered on 17 Nov 2010, 08:14 AM
Hi,

 Have you tried the CellTemplate approach with our grid as well? 

Regards,
Vlad
the Telerik team
See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
0
Victor
Top achievements
Rank 1
answered on 17 Nov 2010, 10:33 PM
Hi,

It's working :)

Thank you
0
Shawn
Top achievements
Rank 1
answered on 20 Jan 2012, 05:44 PM
Hi,
I am trying to get the grid view column tooltip to work and none of the solutions from this post were helpful.


ValidatedInfo is an observable collection of a class(private ObservableCollection<ValidatedCounterReportInfo> ValidatedInfo;) and each column in the grid is associated to a property.
The data displays fine in the grid and everything else works as expected but none of the tooltips are showing up.


Below is the WPF code:
xmlns:TelerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

Can you help me understand the problem here.


Thanks
SN

<TelerikInput:RadGridView ItemsSource="{Binding ValidatedInfo}"
                          SelectionMode="Extended"
                          SelectedItem="{Binding Path=SelectedCell, Mode=TwoWay}"
                          Grid.Row="2"
                          Grid.Column="0"
                          Grid.ColumnSpan="4"
                          IsReadOnly="True"
                          RowIndicatorVisibility="Collapsed"
                          AutoGenerateColumns="False"
                          CanUserFreezeColumns="False"
                          Margin="5"
                          ActionOnLostFocus="None"
                          ShowGroupPanel="False"
                          KeyboardNavigation.AcceptsReturn="True"
                          EnableColumnVirtualization="False">
  <TelerikInput:RadGridView.Columns>
    <TelerikInput:GridViewDataColumn Width="200"
                                DataMemberBinding="{Binding FileName}"
                                EditTriggers="CellClick"
                                ToolTipService.ToolTip="{Binding FileName}"
                                Header="File Name"/>
    <TelerikInput:GridViewDataColumn Width="60"
                                DataMemberBinding="{Binding Type}"
                                EditTriggers="CellClick"
                                ToolTipService.ToolTip="{Binding Type}"
                                Header="Type"/>
    <TelerikInput:GridViewDataColumn Width="60"
                                DataMemberBinding="{Binding Valid}"
                                ToolTipService.ToolTip="{Binding Valid}"
                                Header="Valid">
                                <TelerikInput:GridViewDataColumn.CellTemplate>
                                  <DataTemplate>
                                    <TextBox Text="{Binding Valid, Converter={StaticResource booleanConverter}}"
                                             Foreground="White"
                                             Background="{Binding Valid, Converter={StaticResource backgroundConverter}}"/>
                                  </DataTemplate>
                                </TelerikInput:GridViewDataColumn.CellTemplate>
    </TelerikInput:GridViewDataColumn>
    <TelerikInput:GridViewDataColumn Width="160"
                                DataMemberBinding="{Binding Details}"
                                ToolTipService.ToolTip="{Binding Details}"
                                EditTriggers="CellClick"
                                Header="Details"/>
  </TelerikInput:RadGridView.Columns>
</TelerikInput:RadGridView>
Tags
GridView
Asked by
Rogério
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Rogério
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Celeste
Top achievements
Rank 1
Scott
Top achievements
Rank 1
Naseem
Top achievements
Rank 1
Victor
Top achievements
Rank 1
Shawn
Top achievements
Rank 1
Share this question
or