Expanding 1000+ items freezes application

4 posts, 0 answers
  1. Jinyan
    Jinyan avatar
    23 posts
    Member since:
    Jul 2012

    Posted 21 Aug 2012 Link to this post

    My application freezes when I try to expand a node on RadTreeView that has over 1000 children. Is there anyway to avoid this? I tried using on-demand loading and it doesn't seem to do anything. So it makes me believe that it's the rendering part of the treeview that is clogging the CPU.

    Thanks,
    Jin
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 22 Aug 2012 Link to this post

    Hello Jin,

    Do you databind the RadTreeView control? If so, can you make sure it is virtualized - you can examine this feature here. If this suggestion doesn't help, can you try to isolate the issue in a sample solution and send it over so that we can take a look at it? Thank you in advance.

    Greetings,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Jinyan
    Jinyan avatar
    23 posts
    Member since:
    Jul 2012

    Posted 22 Aug 2012 Link to this post

    That partly solved the issue. Here is my full scenario

    My metadata are as follows:

    class A
    {
        ObservableCollection<B> Bs;
        ObservableCollection<C> Cs;
     
        string name;
    }
     
    class B { string name; }
     
    class C { string name; }

    My templates are as follows
    <!-- NORMAL TREE STRUCTURE A - B - C -->
    <DataTemplate x:Key="CTemplate">
        <TextBlock Text="{Binding Name}" />
    </DataTemplate>
     
    <HierarchicalDataTemplate x:Key="BTemplate"
                ItemsSource="{Binding Path=DataContext.Cs, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadTreeViewItem}, AncestorLevel=1}}"
                ItemTemplate="{StaticResource CTemplate}">
        <TextBlock Text="{Binding Name}" />
    </HierarchicalDataTemplate>
     
    <HierarchicalDataTemplate x:Key="ATemplate"
                ItemsSource="{Binding Path=Bs}"
                ItemTemplate="{StaticResource BTemplate}">
        <TextBlock Text="{Binding Name}" />
    </HierarchicalDataTemplate>
     
     
    <!-- REVERSE TREE STRUCTURE A - C - B -->
    <DataTemplate x:Key="ReverseBTemplate">
        <TextBlock Text="{Binding Name}" />
    </DataTemplate>
    <HierarchicalDataTemplate x:Key="ReverseCTemplate"
          ItemsSource="{Binding Path=DataContext.Bs, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadTreeViewItem}, AncestorLevel=1}}"
          temTemplate="{StaticResource ReverseBTemplate}" >
        <TextBlock Text="{Binding Name}" />
    </HierarchicalDataTemplate>
    <HierarchicalDataTemplate x:Key="ReverseATemplate"
                ItemsSource="{Binding Path=Cs}"
                ItemTemplate="{StaticResource ReverseCTemplate}">
        <TextBlock Text="{Binding Name}" />
    </HierarchicalDataTemplate>


    C is the level of tree that contains a lot of items.

    Essentially, I have a normal tree where the data is organized as A - B - C, and I have a button when the user clicks it changes the DataTemplate to the ReverseATemplate, and reorganizes the tree to A - C - B. In the normal tree structure, everything works perfectly and loading of C data is almost instantaneous. However, when I reverse the tree, loading the C level takes maybe 2 seconds if number of Cs is greater than 1000. Furthermore, scrolling down the tree is now quite laggy.

    Do you have any insights as to why this is happening, and maybe insights on a more elegant solution for changing the tree hierarchy?

    Thanks so much for the help.
    Jin
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 27 Aug 2012 Link to this post

    Hi Jin,

    I am not sure I understand your scenario correctly so I attached a sample solution based on your code samples. Can you please have a look at it and modify it to better demonstrate your approach? Thank you in advance.

    Greetings,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top