Row tooltip

15 posts, 1 answers
  1. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 11 Jun 2012 Link to this post

    Hello Telerik,

    I'm currently using the latest internal build (v2012.1.528.1050) and I'm facing a problem when I try to set a tooltip on a cell (or row). I followed the procedure described here: http://www.telerik.com/help/silverlight/gridview-how-to-create-row-tooltip.html.

    The tooltip is correctly displayed, but as soon as I have collapsed or expanded items, my tooltip is also display for these items but it shouldn't. Basically, I just want to display a tooltip for some type. Here is a part of my code:
    if (row != null && row.Cells != null && row.Cells.Count > 0)
    {
    Task task = row.DataContext as Task;
    if (task != null)
    {
    GridViewCellBase firstCell = row.Cells[0];
    if (firstCell != null)
    {
    // TODO: Not working correctly ????
    ToolTipService.SetToolTip(firstCell, PlanningControlBuilder.CreateTaskTooltip(task));
    }
    }
    }

    This works like a charme for cells with a DataContext of type Task. But for those that have a different type, the tooltip is sometimes also displayed (and sometimes not, it seems to be random??). During my investigations on this bug, I noticed that it happens often when I'm expanding/collapsing an element...

    This problem could also be related to this one: http://www.telerik.com/community/forums/silverlight/treelist/problem-with-itemclick-contextmenu.aspx. In this case, the problem was that one should use Padding instead of Margin...

    Thanks in advance for your help.
    Greetings,

    Nicolas
  2. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 13 Jun 2012 Link to this post

    For information, I do have the same problem with the version 2012.2.607.1050
  3. DevCraft banner
  4. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 14 Jun 2012 Link to this post

    Up ?!
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 14 Jun 2012 Link to this post

    Hello,

    Currently using RowLoaded might not be the most reliable approach to accomplish this task, due to RadGridView's row virtualization. I would highly recommend you to try utilizing a CellStyleSelector. Please, let us know in case you need any further assistance on this.

    Greetings,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 14 Jun 2012 Link to this post

    Hi,

    RowLoaded is the event used in your documentation to accomplish this task:
    http://www.telerik.com/help/silverlight/gridview-how-to-create-row-tooltip.html.

    So?? What !?
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 14 Jun 2012 Link to this post

    Hi,

     The article sets the tooltip for row - not for cells. 

    Regards,
    Vlad
    the Telerik team

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

  8. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 14 Jun 2012 Link to this post

    Hello,

    As I said in my first message, I do have the same problem for cells and rows....
    Greetings
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 14 Jun 2012 Link to this post

    Hi,

     You should never access cells in RowLoaded to set properties since the grid is UI virtual component with container recycling. When you scroll next time this cell will hold different data. 

    Regards,
    Vlad
    the Telerik team

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

  10. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 14 Jun 2012 Link to this post

    Sorry, but I'm not sure to follow you...
    If I modify my code like this:

    if (row != null/* && row.Cells != null && row.Cells.Count > 0*/)
    {
        Task task = row.DataContext as Task;
        if (task != null)
        {
            //GridViewCellBase firstCell = row.Cells[0];
           // if (firstCell != null)
            {
                // TODO: Not working correctly ????
                ToolTipService.SetToolTip(row, PlanningControlBuilder.CreateTaskTooltip(task));
            }
        }
    }


    It doesn't work better....
    Any clue?
    Thanks
  11. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 18 Jun 2012 Link to this post

    Hello Telerik,

    I'm still waiting for an answer so that I can achieve my goal....
    Thanks.

    Nicolas
  12. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 Jun 2012 Link to this post

    Hi Nicolas,

    I have tested the behavior you described with the code from the article mentioned above. However, I was not able to reproduce it. Could you take a look at and let us know in case we are missing something ?
    As for setting ToolTip for the cells, why not following the approach Ivan suggested with cell style selector ? Alternatively, you can try defining a TextBlock for example as CellTemplate and assign it a ToolTip. 

    Greetings,
    Maya
    the Telerik team

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

  13. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 18 Jun 2012 Link to this post

    Hello Maya,

    Thanks for your answer.
    To reproduce the problem, just modify the event handler like this:

     

    private void RadTreeListView1_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
    {
        var row=e.Row as TreeListViewRow;
        if (row != null)
        {
            if (row.DataContext is Club)
            {
                ToolTip toolTip = new ToolTip()
                {
                    Content = row.DataContext,
                };
                ToolTipService.SetToolTip(row, toolTip);
            }
        }
    }

     

    And you will see that for sub-elements, you have a tooltip as well... even if the type is not "Club".
    Greetings,

    Nicolas
  14. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 Jun 2012 Link to this post

    Hello Nicolas,

    Indeed, you are quite correct and that is due to the UI virtualization as mentioned previously. The thing is that once you expand a row, its children reuse the rows previously created (for the parent items). What you can try is to clear the ToolTip on unloading the row. For example:

    void RadTreeListView1_RowUnloaded(object sender, RowUnloadedEventArgs e)
            {
                var row=e.Row as TreeListViewRow;
                if (row != null)
                {
                    ToolTipService.SetToolTip(row, null);
                }
            }
     
            private void RadTreeListView1_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
            {
                var row=e.Row as TreeListViewRow;
                if (row != null)
                {
                    if (row.DataContext is Club)
                    {
                        ToolTip toolTip=new ToolTip()
                        {
                            Content=row.DataContext,
                        };
                        ToolTipService.SetToolTip(row, toolTip);
                    }
                }
            }

    Furthermore, please make sure that you unsubscribe from the events in an appropriate for your application moment, so that no memory leaks could sneak in. 

    All the best,
    Maya
    the Telerik team

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

  15. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 18 Jun 2012 Link to this post

    Setting the ToolTip to null in the Unload event handler solved the problem !
    By the way, it seems to work on the cell level as well (and not only on the row level).

    Thank you Maya.
    Greetings,

    Nicolas
  16. Ashu
    Ashu avatar
    1 posts
    Member since:
    Mar 2010

    Posted 27 Sep 2012 Link to this post

    I tried the solution by setting the tooltip as null in RowUnloded Event but I am getting the following error. This is happening when i view the top row tooltip and scroll the GridView with mouse. This error occurs on the line where the tooltip is set to null.

    {System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, Boolean b)
       at System.Windows.DependencyObject.SetValue(DependencyProperty property, Boolean b)
       at System.Windows.Controls.ToolTip.BeginClosing()
       at System.Windows.Controls.ToolTip.OnIsOpenChanged(Boolean isOpen)
       at System.Windows.Controls.ToolTip.OnIsOpenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter)
       at System.Windows.DependencyObject.SetValue(DependencyProperty property, Boolean b)
       at System.Windows.Controls.ToolTipService.UnregisterToolTip(UIElement owner)
       at System.Windows.Controls.ToolTipService.OnToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter)
       at System.Windows.Controls.ToolTipService.SetToolTip(DependencyObject element, Object value)
       at Halliburton.Web.CrewManagement.UserControls.AvailableResourcesControl.AvailableResourcesGrid_RowUnloaded(Object sender, RowUnloadedEventArgs e)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnRowUnloaded(RowUnloadedEventArgs e)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.ClearContainerForItemOverride(DependencyObject element, Object item)
       at Telerik.Windows.Controls.GridView.BaseItemsControl.Telerik.Windows.Controls.GridView.IGeneratorHost.ClearContainerForItem(DependencyObject container, Object item)
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.UnlinkContainerFromItem(DependencyObject container, Object item, Boolean isRecycled)
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(GeneratorPosition position, Int32 count)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.CleanupContainers(Int32 firstViewport, BaseItemsControl itemsControl)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)} 

    Any solution for this ? Need it urgently.
Back to Top
DevCraft banner