Search code examples
.netwpftreeviewvirtualization

TreeView Virtualization


we're trying to come up with a good way to virtualize the TreeView, the data is not really a problem because it's very light (around 16 bytes per item), the problem is that we could potentially have tens of thousands, and although the actual data would only take 160 kb of memory, the treeview items do use a lot more memory. We've tried virtualization with 3 different trees now, WPF, Infragistics and Telerik. All of them have big issues that makes them unusable for our application:

WPF TreeView: The scroll bar shows some weird behavior, jumps around a lot, changes size inconsistently, scrolling by dragging it with the mouse doesn't work properly (jumps back and forth)

Telerik: Items disappear, scroll bar is erratic too, items randomly expand collapse, styles don't work

Infragistics: Items are not virtualized at all, every item remains in memory making virtualization useless.

We've been struggling with this a couple of months now, and we haven't been able to find a good solution. Has any of you successfully implemented virtualization in a TreeView with more than 9000 items? If so, what was your strategy? Did you use third party controls? Did it work 100%?

Any suggestion extremely appreciated.

Thanks.


Solution

  • We've used Bea Costa's Stollnitz's trick of indenting items in a ListView and using UI Virtualization to good effect.

    http://www.beacosta.com/blog/?p=45

    I've gotten 100,000 items in the backing ICollectionView, and it is still quite responsive to filtering, etc.