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

Programatic access to Template items

1 Answer 72 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 05 Nov 2008, 04:32 PM
How can I set values for items in a template from code?
I'm adding RadTreeViewItems to a treeview in code, and I need to set values on additional controls I've added to the template.

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 06 Nov 2008, 04:54 PM
Hi Sean,

You can use VisualTreeHelper.GetChild method to get the visuals from the RadTreeViewItem template but this is not the recomended way.
The good way is to inherit RadTreeViewItem add some properties to hold your data, modify the RadTreeViewItem template to include your control and bind it to your data property. Or the easier way is to put the your data into RadTreeViewItem Tag property and bind your control to the Tag prop but this has some limitation.

If you have more questions, I'll be glad to help.

Regards,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Sean
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or