Highlighting selected TreeView Item

3 posts, 0 answers
  1. Martin
    Martin avatar
    18 posts
    Member since:
    Oct 2018

    Posted 02 Oct 2018 Link to this post


    I'm already testing Xamarin UI Trial with looking forward to buy it. Is there a way to implement a highlighting of a TreeView Item on selection / tap and to set the selected TreeView Item programmatically / with databinding? With highlighting I for instance mean setting a blue background color to the item. I also need to know when an TreeView Item is selected, but therefore I found the event "ItemTapped" on RadTreeView, right?


    Thank you,


    regards Martin

  2. Lance | Manager Technical Support
    Lance | Manager Technical Support avatar
    1185 posts

    Posted 02 Oct 2018 Link to this post

    Hello Martin,

    You can define an ItemTemplate that changes the color of any of the template's UI elements based on a value of your data model and use ItemTapped to change the value of that model property

    I've attached a demo that changes the color of the text from Black to Blue when you tap on any of the nodes.  If you want the background to change, you can use the same approach for any other items in the data template.

    Further Assistance

    Taking a look at the customization example source code in the QSF demo, we have other examples as well in the SDKExamples browser. I also recommend reading these two blog posts from Pavel, one of the TreeView developers:

    1 - First Impressions
    2 - Deep Dive

    If you have any problems with using DataTemplates or selectors, open a support ticket here and share the code so that the TreeView team can assist directly.

    Lance | Tech Support Engineer, Sr.
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Martin
    Martin avatar
    18 posts
    Member since:
    Oct 2018

    Posted 04 Oct 2018 in reply to Lance | Manager Technical Support Link to this post

    Hello Lance,

    many thanks, with the code from your attached demo it works fine now. The LevelToMarginConverter was really helpfull too. It also solved my problem that all subnodes were on the same Level as their parent nodes.

    In the QSF demo in the treeview country example in "CustomizationView.xaml" the LevelToMarginConverter is not used. That's why I did not know about, and maybe that leads to the problem I descibed here:





Back to Top