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

Show tooltip on node if the node name is cut off

5 Answers 141 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
rico
Top achievements
Rank 1
rico asked on 25 Aug 2017, 06:33 AM

I use the Telerik libraries 2014.2.811.45.

I have a tree which can be edited by the user. The user as well can adjust the width of the tree and make it narrow enough to cut off some of the node names.

This post here (http://www.telerik.com/forums/treeview-tooltips-instead-of-horizontal-scroll-bar) seems to solve the problem but is unfortunately outdated. The API has changed meanwhile - the functions/properties don't exist any more.

Still I tried to adjust the solution to my library version but I couldn't get it work. The solution gets the bounds of the tree and each of its items and compares them. This seems to be an easy and adequate solution which I would like to use as well. Trying out different properties showed me the following: Width seems to return NaN. ActualWidth seems to return pretty much the width of the tree whether it is called on the tree or the node. I would expect it to return the width of the node name if called on the node. Further I could not find a property to get the right border of the tree/items.

How can I solve this problem with my telerik libraries?

5 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 29 Aug 2017, 08:23 AM
Hello Rico,

There is an SDK example showing how to achieve your requirement. Can you please give it a try and let me know if it works for you?

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
rico
Top achievements
Rank 1
answered on 05 Sep 2017, 08:16 AM

Thank you for your answer.

In the example project it works. Unfortunately my real project does not know the ShowTooltipWhenNodeIsClipped namespace and the TextBlockUtils.ShowToolTipWhenClipped property. When was this feature added? I use the Telerik libraries 2014.2.811.45.

0
Martin Ivanov
Telerik team
answered on 05 Sep 2017, 12:33 PM
Hello Rico,

ShowTooltipWhenNodeIsClipped is the namespace of the SDK example. The TextBlockUtils class is defined there. In order to use it you should copy it into your application and use your namespace.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
rico
Top achievements
Rank 1
answered on 07 Sep 2017, 11:05 AM

Thank you, putting your code into our project makes it work.

I don't understand though why our solution doesn't work. On MouseOver on the label we calculate whether the label is clipped or not. If so, we set a property IsClipped to true. In the xaml we have a trigger which sets the tooltip of the label when the IsClipped property is set to true:

<Style TargetType="{x:Type MyLabel}">

    <Style.Triggers>

        <Trigger Property="IsClipped" Value="True">

            <Setter Property="ToolTip" value="{ Binding RelativeSource = { RelativeSource Self }, Path=Text }" />

        </Trigger>

    <Style.Triggers>

<Style>

This works perfectly. If the labels are in the HierarchicalDataTemplate it doesn't work anymore though. Do you have an idea why?

0
Martin Ivanov
Telerik team
answered on 11 Sep 2017, 06:39 PM
Hello Rico,

I am afraid that without your implementation I cannot tell why this happens. If the solution from the SDK doesn't work for your you can share some runnable code demonstrating your set up and I can check what happens.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
TreeView
Asked by
rico
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
rico
Top achievements
Rank 1
Share this question
or