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

Row tooltip

14 Answers 105 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
AKROS
Top achievements
Rank 1
AKROS asked on 11 Jun 2012, 11:35 AM
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

14 Answers, 1 is accepted

Sort by
0
AKROS
Top achievements
Rank 1
answered on 13 Jun 2012, 06:48 AM
For information, I do have the same problem with the version 2012.2.607.1050
0
AKROS
Top achievements
Rank 1
answered on 14 Jun 2012, 10:51 AM
Up ?!
0
Ivan Ivanov
Telerik team
answered on 14 Jun 2012, 11:14 AM
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 >>
0
AKROS
Top achievements
Rank 1
answered on 14 Jun 2012, 11:50 AM
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 !?
0
Vlad
Telerik team
answered on 14 Jun 2012, 11:52 AM
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 >>

0
AKROS
Top achievements
Rank 1
answered on 14 Jun 2012, 11:55 AM
Hello,

As I said in my first message, I do have the same problem for cells and rows....
Greetings
0
Vlad
Telerik team
answered on 14 Jun 2012, 11:57 AM
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 >>

0
AKROS
Top achievements
Rank 1
answered on 14 Jun 2012, 12:06 PM
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
0
AKROS
Top achievements
Rank 1
answered on 18 Jun 2012, 08:03 AM
Hello Telerik,

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

Nicolas
0
Maya
Telerik team
answered on 18 Jun 2012, 11:02 AM
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 >>

0
AKROS
Top achievements
Rank 1
answered on 18 Jun 2012, 11:31 AM
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
0
Accepted
Maya
Telerik team
answered on 18 Jun 2012, 11:59 AM
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 >>

0
AKROS
Top achievements
Rank 1
answered on 18 Jun 2012, 12:13 PM
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
0
Ashu
Top achievements
Rank 1
answered on 27 Sep 2012, 09:13 AM
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.
Tags
TreeListView
Asked by
AKROS
Top achievements
Rank 1
Answers by
AKROS
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Vlad
Telerik team
Maya
Telerik team
Ashu
Top achievements
Rank 1
Share this question
or