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

self-referencing data source

5 Answers 106 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jerzy Rzaniak
Top achievements
Rank 1
Jerzy Rzaniak asked on 08 Nov 2008, 10:34 AM
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

5 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 08 Nov 2008, 11:14 AM
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.
0
Jerzy Rzaniak
Top achievements
Rank 1
answered on 09 Nov 2008, 11:31 AM
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
0
Valentin.Stoychev
Telerik team
answered on 10 Nov 2008, 04:56 PM
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.
0
WILLIAM
Top achievements
Rank 1
answered on 04 Aug 2012, 11:21 PM
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.
0
WILLIAM
Top achievements
Rank 1
answered on 06 Aug 2012, 01:56 PM
I figured it out.  Thanks!
Tags
TreeView
Asked by
Jerzy Rzaniak
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Jerzy Rzaniak
Top achievements
Rank 1
WILLIAM
Top achievements
Rank 1
Share this question
or