Pouplate Data in RadTreeView via collection

2 posts, 0 answers
  1. Harsh
    Harsh avatar
    8 posts
    Member since:
    Jan 2009

    Posted 29 Jan 2009 Link to this post

    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?

     

     





  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 30 Jan 2009 Link to this post

    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.
Back to Top