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

Pouplate Data in RadTreeView via collection

1 Answer 38 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Harsh
Top achievements
Rank 1
Harsh asked on 29 Jan 2009, 10:03 AM
I have a collection which contains two properties
1. ABC
2. XYZ

I want to make XYZ as the child of ABC For example:

.ABC1
    .XYZ1
    .XYZ2
.ABC2
    .XYZ3
    .XYZ4

I want to bind this in .XAML.CS page

Currently what I have done in XAML

 

<Telerik:RadTreeView x:Name="RadTreeView" DockPanel.Dock="Bottom"/>

 

 


In XAML.CS page
Collection is CommodityCollection

RadTreeViewItem

aa;

 

 

 

 

 

for (int i = 0; i < CommodityCollection.Count; i++) {

 

aa = new RadTreeViewItem();

 

 

 aa.Header = CommodityCollection[i].ABC;

 

this.RadTreeView.Items.Add(aa);


Now my problem is How to add child node in the RadTreeView?

 

 





1 Answer, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 30 Jan 2009, 08:33 AM
Hi Harsh,

You can get the items that you have added in the root levev by using

RadTreeViewItem item = this.RadTreeView.Items[0] as RadTreeViewItem;

and then to use its Items collection to add the childs.

item.Items.Add(....);

Please let us know if you have any other questions!


Regards,
Valentin.Stoychev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Harsh
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Share this question
or