self-referencing data source

6 posts, 0 answers
  1. Jerzy Rzaniak
    Jerzy Rzaniak avatar
    13 posts
    Member since:
    Aug 2004

    Posted 08 Nov 2008 Link to this post

    I try to find an example how to display self-referencing data in TreeView for Silverlight.
    Is this so easy or so heavy to show how to use self-referencing data sources with unlimited (a priori unknown) levels?
    Regards
    Jerzy Rzaniak
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 08 Nov 2008 Link to this post

    Hi Jerzy Rzaniak,

    Yes - it is easy - you just need to set the proper HierarchicalTemplate that binds to the collection containing the childs.
    <core:HierarchicalDataTemplate x:Key="ItemsTemplate"   
                    ItemsSource="{Binding TheChildProperty}">  
                ....  
    .....  
            </core:HierarchicalDataTemplate> 
     

    You can check this sample for more info:
    http://demos.telerik.com/silverlight/#TreeView/DataBinding

    Let us know if you have more info.

    Greetings,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Jerzy Rzaniak
    Jerzy Rzaniak avatar
    13 posts
    Member since:
    Aug 2004

    Posted 09 Nov 2008 Link to this post

    Hi,
    probably i very very new in silverlight world ;-) but  self-referencing data source for me is one and only one collection that contains parent and child  records. The relation is realized not through object model but parent / child id fields.
    In other words, there is no child data source other then parent.
    regards
    jr
  5. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 10 Nov 2008 Link to this post

    Hello Jerzy Rzaniak,

    I see now. We are not supporting this scenario. The TreeView control is an ItemsControl which binds to ItemCollection. You need to manually build an hierarchical collection out of your self-referencing data and then to bind that collection to the RadTreeView.

    To build a hierarchical collection you can use LINQ. Check this article on how to implement this:
    http://www.scip.be/index.php?Page=ArticlesNET18

    Let us know if you need more help on implementing that.

    Greetings,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 04 Aug 2012 Link to this post

    Am I understanding this correctly, that I can't set a datasource to the TreeView and then set a parent property and a child property??

    Isn't this common functionality?  This is the first TreeView that I've come across that doesn't support this.
  7. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 06 Aug 2012 Link to this post

    I figured it out.  Thanks!
Back to Top
DevCraft banner