How to do recursive template

2 posts, 0 answers
  1. Tim
    Tim avatar
    2 posts
    Member since:
    Apr 2008

    Posted 21 Oct 2008 Link to this post

    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.


  2. Tim
    Tim avatar
    2 posts
    Member since:
    Apr 2008

    Posted 21 Oct 2008 Link to this post

    It looks like the TemplateSelector example provides a solution for this. 


Back to Top