Treeview dynamic binding

3 posts, 0 answers
  1. Noushad
    Noushad avatar
    10 posts
    Member since:
    Feb 2009

    Posted 11 Aug 2011 Link to this post

    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. Noushad
    Noushad avatar
    10 posts
    Member since:
    Feb 2009

    Posted 11 Aug 2011 Link to this post

    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. 
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Aug 2011 Link to this post

    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 >>

Back to Top