WPF TreeView Virtualization

不羁岁月 提交于 2019-12-03 22:57:34

The difference is UI virtualization (which WPF supports out of the box on varying controls) versus data virtualization (which WPF does not support out of the box).

It boils down to UI virtualization only rendering what is needed and within view; while data virtulization only holding what may be needed at a given time in memory.

Bea has two great posts about UI virtualization and data virtualization and goes into the differences and how to workaround the limitation of no support for data virtualization which appears to be what you are after.

EDIT:

As of 3.5 SP1 support for virtualization was added to the TreeView. Perhaps removing your ItemsPanel template and just setting the properties on the TreeView should suffice.

Ok, the problem is that virtualization only works when the TreeView is using Binding, and not when the nodes are generated one by one in the code like my example. What a bummer.

Thats not accurate. True that virtualuzation only works with binding, however, as I observed in some sample application is that recycling of elements occur only on the root items of the treeview.

so if you have only 1 root item with 1000 children, no recycling will occur because theres only 1 container available for recycling.

if you have 100 root items, and each of them has 100 children, you will get partial recycling, because only the root 100 items will be recycled, but other 9900 child items will be stored in memory.

of course the problem gets only worse if your tree nesting level is greater than 2 or 3.

I dont know if theres a solution to this problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!