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

How to do recursive template

1 Answer 109 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 21 Oct 2008, 08:23 PM
Hi,

I'm just getting started with these controls.  I'm trying to bind a treeview to a hierarchical datasource of unknown/variable depth.  It's recursive.  The datasource is built from CategoryItems.  Each CategoryItem in the CategoryList has a Children property of type CategoryList, containing 0 or more CategoryItems.

If I have a HierarchicalDataTemplate named/keyed MyTemplate, it seems like I should set MyTemplate's  ItemTemplate property to "MyTemplate" in order to make it recursive.  I can't see how to do that if it is a static resource (errors - "cannot find a resource named 'MyTemplate'").

Do I have to have a different HierarchicalDataTemplate defined for every possible nesting level?  Is there a way to assign the ItemTemplate programmatically? Which event would I do that in?

Thx.


1 Answer, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 21 Oct 2008, 08:58 PM
It looks like the TemplateSelector example provides a solution for this. 


Tags
TreeView
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Share this question
or