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
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
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 !?
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 >>
As I said in my first message, I do have the same problem for cells and rows....
Greetings
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 >>
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
I'm still waiting for an answer so that I can achieve my goal....
Thanks.
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.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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
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 >>
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
{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.