Scrolling bug in WPF virtualized Treeview

后端 未结 1 1563
孤城傲影
孤城傲影 2021-01-13 14:43

I\'m using a virtualized treeview in WPF to display a 3 level deep hierarchy with a larger number of child nodes (5000+).

<         


        
相关标签:
1条回答
  • 2021-01-13 15:25

    have you tryed to load the items lazy?? What i mean is that you could load at first (without virtualizing) only the root nodes, and then when each one of those nodes are expanded load it's childs.

    I usually use a TreeViewItemViewModelClass in this cases, something like:

    public class TreeViewItemViewModel : INotifyPropertyChanged
    {
        public IEnumerable<TreeViewItemViewModel> Childs { get; }
        public bool IsSelected { get; set; }
        public bool IsExpanded { get; set; }
        (...)
    }
    

    and then in the ItemContainerStyle of the TreeView with a TwoWay binding bind the IsSelected and the IsExpanded propertires, and then in the setter of the property IsExpanded you load all it's childs.

    I have tested this approach, with trees that in theory have more than 5000 items but never with all the items loaded at the same time.

    Hope this helps...

    0 讨论(0)
提交回复
热议问题