I am using TreeviewList in my WPF appication using MVVM. I want to show all nodes in expanded mode but by default it shows me only parent node. Is there any way to show all nodes (in expanded mode) automatically?
6 Answers, 1 is accepted
I suggest you check the following help article that should get you started:
http://www.telerik.com/help/wpf/treelistview-expand-all-hierarchy.html
Hope this helps.
Nick
the Telerik team

I have a similar question in expanding the tree. I followed the example and was able to expand the tree when View was first initialized. However, if the entire collection was changed, I wasn't able to fire the event to expand the tree. I'm using MVVM model. The collection was implemented as ObservableCollection. I have to re-create the view in order to fire the event. Is there a event in TreeViewList when the data is completed?
public PipeSegmentView() { this.pipeTreeListView.DataLoaded += new EventHandler<EventArgs>(pipeTreeListView_DataLoaded); } private void pipeTreeListView_DataLoaded(object sender, EventArgs e) { this.pipeTreeListView.DataLoaded -= new EventHandler<EventArgs>(pipeTreeListView_DataLoaded); this.pipeTreeListView.ExpandAllHierarchyItems(); }
I have tried to reproduce the issue you reported, but I was not able to. I am sending you the sample project I used for the test. Please take a look at it and let me know in case of any misunderstandings.
Maya
the Telerik team

Thanks for the quick response! The DataLoad event worked just fine to expand the tree, I actually referred to how to re-expand the tree if the datasource was reloaded with a different set of data. Please find the attached modification of your example. In the example, you will see "Refresh Data" button, which will fetch a different tree-like data (GetClubs2). Because the DataLoaded event was removed after the data was loaded, the event won't be fired again. I tried to take keep this event, but error occurred when the entire datasource was updated.
void RadTreeListView1_DataLoaded(object sender, EventArgs e) { this.RadTreeListView1.DataLoaded -= new EventHandler<EventArgs>(RadTreeListView1_DataLoaded); this.RadTreeListView1.ExpandAllHierarchyItems(); }My question is how to re-trigger this event, if the data model is updated. I have a RoutedCommand that will update the datasource in the VM, and not using the codebehind as I did in the example.
Thanks for helping!
Cheau-Long
Generally, the idea behind calling the ExpandAllHierarchyItem() method in the DataLoaded event is that you need to make sure all the elements are loaded as well as the items themselves.
You mentioned that you updated the sample project I attached previously, but unfortunately I am not able to see any files attached. May you try to resend it so that I can see your exact requirements ?
Basically, I have tested the sample by handling a Click event of a button, changing the ItemsSource there and calling that very method. However, it all works appropriately and the parent rows are expanded. Is that the scenario you tried ?
Maya
the Telerik team

I am faced with this challenge as well. Did you manage to find a suitable solution?
Thanks,
Mark