question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TreeView is very slow with many loaded objects

See original GitHub issue

Describe the bug With many objects loaded into the tree, scrolling and general application responsiveness are negatively affected

To Reproduce Steps to reproduce the behavior:

Load many objects with hierarchy into a TreeView. Expand all expandable nodes. Testing here with 5000 entries.

Expected behavior TreeView should be able to handle many entries (possibly via virtualization?)

Desktop (please complete the following information):

Tested on Windows 10 and RHEL 8

Additional context Tree objects look like this:

    public interface ITreeItem
    {
        public int          DatabaseId { get; set; }
        public bool         IsExpanded { get; set; }
        public bool         IsChecked  { get; set; }
        public string       Name       { get; set; }
        public List<string> Tags       { get; set; }
    }
    public class TreeEndpoint : ReactiveObject, ITreeItem
    {
        public            int          DatabaseId { get; set; }
        [Reactive] public bool         IsExpanded { get; set; }
        [Reactive] public bool         IsChecked  { get; set; }
        [Reactive] public string       Name       { get; set; }
        public            List<string> Tags       { get; set; }
    }
    public class TreeGroup : ReactiveObject, ITreeItem
    {
        public            int          DatabaseId { get; set; }
        [Reactive] public bool         IsExpanded { get; set; }
        [Reactive] public bool         IsChecked  { get; set; }
        [Reactive] public string       Name       { get; set; }
        public            List<string> Tags       { get; set; }

        [Reactive] public ObservableCollection<ITreeItem> Children { get; set; }
    }

TreeView bindings look like this:

                <TreeView Items="{Binding Items}"
                          SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                          ClipToBounds="True">
                    <TreeView.Styles>
                        <Style Selector="TreeViewItem">
                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
                        </Style>
                    </TreeView.Styles>
                    <TreeView.DataTemplates>
                        <TreeDataTemplate DataType="treeDataStructures:TreeGroup"
                                          ItemsSource="{Binding Children}">
                            <VirtualizingStackPanel Classes="treeListItem"
                                        Orientation="Horizontal"
                                        ClipToBounds="True">
                                <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}">
                                    <!-- <Interaction.Behaviors> -->
                                    <!--     <ButtonClickEventTriggerBehavior> -->
                                    <!--         <InvokeCommandAction Command="{Binding $parent[UserControl].DataContext.SetCheckedState}" -->
                                    <!--                              CommandParameter="{Binding}"/> -->
                                    <!--     </ButtonClickEventTriggerBehavior> -->
                                    <!-- </Interaction.Behaviors> -->
                                </CheckBox>
                                <TextBlock Foreground="Red" 
                                           Text="{Binding Name}" />
                            </VirtualizingStackPanel>
                        </TreeDataTemplate>
                        <DataTemplate DataType="treeDataStructures:TreeEndpoint">
                            <VirtualizingStackPanel Classes="treeListItem"
                                                    Orientation="Horizontal"
                                                    ClipToBounds="True">
                                <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}"/>
                                <TextBlock Text="{Binding Name}" />
                            </VirtualizingStackPanel>
                        </DataTemplate>
                    </TreeView.DataTemplates>
                </TreeView>

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
grokyscommented, Sep 18, 2021

@SCLDGit is this for a commercial application? Would you be willing to pay for a commercial control for this? If so we might have a solution.

0reactions
KvanTTTcommented, Sep 21, 2021

@SCLDGit Can you provide examples? I have never seen a case where so many items need to be loaded at once in a TreeView. Perhaps 3D/graphics software only?

Something like AST or parse tree exploring. For instance, https://astexplorer.net/ but offline.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Slow expanding and collapsing TreeView nodes
1 Answer 1 ... Both TreeView and TreeViewItem do not contain IncrementalLoading behavior, so you can't make increment loading for treeview. But ...
Read more >
very slow performance on big TreeView refresh
By using the load() method, the entire TreeView will be rendered again, so multiple DOM elements needs to be recreated and processed and ......
Read more >
TreeView is very slow. Any performance tips?
The desktop app can populate the winforms treeview with 500,000 items and display them without any lag. The Wisej Treview cant even display ......
Read more >
TreeView is extremely slow in searching/rendering
The performance is slow because TreeView renders all loaded nodes on the page. Technically, you can get full control over nodes and load...
Read more >
Thread: Speed Up TreeView
Currently there are 2 things that are really slow, loading the tree when you initially start up and also doing an expand and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found