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

Treeview dynamic binding

2 Answers 84 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Noushad
Top achievements
Rank 1
Noushad asked on 11 Aug 2011, 12:50 PM

I am using WPF MVVM and have used the HierarchicalDataTemplate to bind my hierichical data to my RadTreeView. However I am having performance issues. There is a large amount of data that needs to be bound and its not efficient to load all the data and then attempt to use LoadOnDemand as a means to improve the performance. I basically need to load the child items of the current item only once the expander is expanded. For each item I know whether it has children from a property that is returned with the data so I need in some way to have the expander indicate that there are children by using this property without the data preloaded and only when the expander is clicked must it go and load its children.

I have tried to get the data for two levels so that the expander appears however this is not ideal and impacts on performance. Thanks for your help.

2 Answers, 1 is accepted

Sort by
0
Noushad
Top achievements
Rank 1
answered on 11 Aug 2011, 03:58 PM
I resolved all the issues that I had with regard to dynamically binding to the Treeview and indicating whether or not an item has children.  I managed to get dynamic binding to work by setting IsLoadOnDemandEnabled to True and using the LoadOnDemand event.  I had to add a style trigger to the Expander style to hide the ToggleButton when there are no children in XAML and also set IsLoadingOnDemand to false when in the LoadOnDemand event handler method when there are no children. 
0
Tina Stancheva
Telerik team
answered on 16 Aug 2011, 10:22 AM
Hi Noushad,

I am glad to hear that you resolved your issues. I just wanted to suggest taking advantage of the virtualization feature of the RadTreeView control if you are displaying large amounts of data. It can further improve the performance of the control.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
TreeView
Asked by
Noushad
Top achievements
Rank 1
Answers by
Noushad
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or