Expanded Event issue

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

    Posted 03 Feb 2009 Link to this post

    Hi,
       I am using expanded event of the WPF Treeview to populate children of the parent node when the parent node is clicked.

    I am binding my treeview with the collection. Collection has 2 things
    a. Name
    b. Commodity

    On page load:

    this

    .RadTreeView.Items.Add(new RadTreeViewItem()

     

    {

    Header = "Name"

     

    });

     

    this.RadTreeView.Items.Add(new RadTreeViewItem()

     

    {

    Header = "Commodity"

     

    });

    Now I want to show the children under commodity on click of commodity (parent node).

     

    private

    void RadTreeView_Expanded(object sender, Telerik.Windows.RadRoutedEventArgs e) { 

     

     

     

     

     

    RadTreeView objRadTreeView = sender as RadTreeView;

     

     

     

    RadTreeViewItem objRadItem = e.OriginalSource as RadTreeViewItem;

     

     

     

    CommodityCollection objCommodityCollection = this.CommodityCollection;

     

     

     

     

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

     

     

     

     

     

     

    objRadItem.Items.Add(

    objCommodityCollection[i].CommodityName);

     

     

     

        }
    }

     

    Now the issue is when I run the application, as currently there are no child for commodity I am not getting expand icon on the left side of commodity (when the page is loaded) because of which Expanded event is not called.

    How to resolve this issue?

     

     

     

  2. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 03 Feb 2009 Link to this post

    Hello Harsh,

    Please refer to the following two blog posts:

    http://blogs.telerik.com/ValentinStoychev/Posts/08-08-05/How_to_Databind_RadTreeView_in_WPF.aspx
    http://blogs.telerik.com/valerihristov/posts/08-10-08/Silverlight_TreeView_Load_on_Demand.aspx

    I believe these article clarify what you want to know - let me know if you still need assisstance after reading them.

    Best wishes,
    Tihomir Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top