RadTreeview with MVVM and dynamic children

heavywoody

I am porting an existing WPF application to MVVM pattern and I am using the RadTreeView. I am dynamically populating the Items collection at runtime of the RadTreeViewItem depending on whether a user has selected a Category node or a Object node.

In a MVVM pattern, I am unsure of how to do this while preserving the state of the Treeview (selected, what is expanded). So what would I do in the ViewModel and View to have this work? Would I have to create a class that would emulate the Items collection? How do I preserve the state?

Tina Stancheva

You can bind the RadTreeView to a hierarchical data illustrating the described hierarchy and use ContainerBindingCollection to bind the IsExpanded and IsSelected properties of the RadTreeViewItem. You can find more info in this article. It should help you get started. Still, if you need more info, please let us know.

Regards,
Tina Stancheva
the Telerik team

Browse the videos here>> to help you get started with RadControls for WPF

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.