Show tooltip on node if the node name is cut off

6 posts, 1 answers
  1. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 25 Aug Link to this post

    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?

  2. Answer
    Martin Ivanov
    Admin
    Martin Ivanov avatar
    1410 posts

    Posted 29 Aug Link to this post

    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.
  3. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 05 Sep in reply to Martin Ivanov Link to this post

    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.

  4. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1410 posts

    Posted 05 Sep Link to this post

    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.
  5. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 07 Sep in reply to Martin Ivanov Link to this post

    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?

  6. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1410 posts

    Posted 11 Sep Link to this post

    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.
Back to Top