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

Highlighting selected TreeView Item

2 Answers 265 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 02 Oct 2018, 07:48 AM

Hello,

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 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 02 Oct 2018, 06:39 PM
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.


Regards,
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
0
Martin
Top achievements
Rank 1
answered on 04 Oct 2018, 11:45 AM

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:

https://www.telerik.com/forums/android---treeview-item-expand-issue-bug

 

regards,

Martin

Tags
TreeView
Asked by
Martin
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Martin
Top achievements
Rank 1
Share this question
or