Programatic access to Template items

2 posts, 0 answers
  1. Sean
    Sean avatar
    2 posts
    Member since:
    Nov 2008

    Posted 05 Nov 2008 Link to this post

    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.
  2. Hristo
    Hristo avatar
    832 posts

    Posted 06 Nov 2008 Link to this post

    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.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top