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?