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

Expanded Event issue

1 Answer 81 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Harsh
Top achievements
Rank 1
Harsh asked on 03 Feb 2009, 06:19 AM
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?

 

 

 

1 Answer, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 03 Feb 2009, 01:58 PM
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.
Tags
TreeView
Asked by
Harsh
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Share this question
or