Custom RadToolTip with ShowDuration set on a GridViewDataColumn

4 posts, 0 answers
  1. Alexander
    Alexander avatar
    2 posts
    Member since:
    Jun 2014

    Posted 18 Jun 2014 Link to this post

    On a RadWindow, I have a RadGridView whose columns represent a subset of the schema associated with the data behind the RadGridView.  I am able to display a tooltip that shows the entire schema, with each field\value on its own line.  I am accomplishing this by assigning the ToolTipTemplate property of each GridViewDataColumn to a StaticResource I created that has my DataTemplate for the tooltip behind it.

    My issue is that the tooltip only stays open for about 5 seconds (a Silverlight default I believe).  Because of this, I've tried a different approach to get my desired behavior.  Instead of assigning my DataTemplate to the ToolTipTemplate property, I tried assigning it to the RadToolTipService.ToolTipContentTemplate property, as well as setting the RadToolTipService.ShowDuration property to something larger than 5 seconds (60 sec in the following column):

    <telerik:GridViewDataColumn Header="Name" telerik:RadToolTipService.ToolTipContentTemplate="{StaticResource TooltipTemplate}" telerik:RadToolTipService.ShowDuration="60000" DataMemberBinding="{Binding QueryName}" IsReadOnly="True" IsFilterable="False"/>

    However, when I do this, Visual Studio tells me that it is Unable to cast object of type 'Telerik.Windows.Controls.GridViewDataColumn' to type 'System.Windows.FrameworkElement'. 

    Now here's something strange.  I have an existing RadToolTip in a different part of my application.  It is on a framework Checkbox that sits on a framework UserControl.  The RadToolTip is added to the Checkbox by nesting the ShowDuration, etc. properties within the Checkbox like so:

    <Checkbox>
           <telerik:RadToolTipService.ShowDuration>60000</telerik:RadToolTipService.ShowDuration>
           <telerik:RadToolTipService.ToolTipContentTemplate>
               <DataTemplate>
                   <StackPanel>
                           .......I have some controls in here..............
                   </StackPanel>
               </DataTemplate>
           </telerik:RadToolTipService.ToolTipContentTemplate>
    </Checkbox>


    This works, but when I try to place the same Checkbox verbatium on my RadWindow from above, the tooltip won't show up, although I've seen the mouse pointer flash to the blue circular busy indicator for a blink of an eye (almost like it loaded something, but there wasn't anything to load).

    So from all of this, I guess there are 2 questions:

    1.)  Why is it that I can set the RadToolTipService.ToolTipContentTemplate and other Telerik specific properties on a framework control like my CheckBox, but not on a Telerik control like a RadWindow or GridViewDataColumn without Visual Studio complaining about casting issues?

    2.)  Why wouldn't my existing\working RadToolTip show up on my CheckBox after I simply moved it from a hosting UserControl to a RadWindow?
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 23 Jun 2014 Link to this post

    Hello Alexander,

    The exception: Unable to cast object of type 'Telerik.Windows.Controls.GridViewDataColumn' to type 'System.Windows.FrameworkElement'.  
    is expected, because the GridViewDataColumn type does not inherit from FrameworkElement, thus the column is not a visual element. That is why you can not set the telerik:RadToolTipService.ToolTipContentTemplate to a DataTemplate directly on the GridViewDataColumn. Instead you can set it to an element in the CellTemplate of the column.

    <telerik:RadWindow.Resources>
            <DataTemplate x:Key="myToolTipTemplate">
                    <TextBlock Text="{Binding}" />
        </DataTemplate>
    </telerik:RadWindow.Resources>
     
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}"
                                           telerik:RadToolTipService.ShowDuration="60000"
                                           telerik:RadToolTipService.ToolTipContent="MyToolTipText"
                                           telerik:RadToolTipService.ToolTipContentTemplate="{StaticResource myToolTipTemplate}" />
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

    For more information on how to add a ToolTip you can check the Add ToolTip for columns and headers documentation article.

    Also, I attached a sample project that demonstrates the suggested approach.

    Please let us know if this helps or not.

    Regards,
    Boris Penev
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Alexander
    Alexander avatar
    2 posts
    Member since:
    Jun 2014

    Posted 23 Jun 2014 in reply to Boris Link to this post

    Thank you so much for the reply!

    I tried out the approach you supplied, but unfortunately it didn't seem to work.  When I hover over a cell with that approach in place, no tooltip comes up at all.  To try and narrow down the issue, I simplified the approach by removing the assignment of the Telerik:RadToolTipService.ToolTipContentTemplate property altogether, so that I have the following:

    ​<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding QueryName}">
        <telerik:GridViewDataColumn.CellTemplate>
             <DataTemplate>
                <TextBlock Text="{Binding QueryName}">
                         <telerik:RadToolTipService.ToolTipContent>this should be a tool tip</telerik:RadToolTipService.ToolTipContent>
                </TextBlock>
            </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
    </telerik:GridViewDataColumn>


    Above, I'm just trying to get a hard coded tooltip to come up, but it doesn't. 

    I also tried to run the example project you supplied, but I can't get it to build.

    Do you have any other approaches?
  5. Boris
    Admin
    Boris avatar
    276 posts

    Posted 25 Jun 2014 Link to this post

    Hello Alexander,

    It is strange that both approaches do not work on your end. As for the sample project could you please check if it has referenced all the .dll files from the Libs folder? Another thing you can try if the solution still does not build is to clear and rebuild it again. In addition I reattached the project.

    However, if you still have issues could you please edit the sample project to match your case?

    Regards,
    Boris Penev
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top