The best example I've ever seen is TreeView by Josh Smith . It uses load loading on demand and has text search.
To enable DataVirtualization
, you should use:
<TreeView VirtualizingStackPanel.IsVirtualizing = "True" VirtualizingStackPanel.VirtualizationMode = "Recycling" />
But be careful, Virtualization
only works when TreeView
uses Binding
, and not when nodes are generated one after another in code, as in the following example:
TreeViewItem rootItem = new TreeViewItem() { Header = "Item Level 0" }; for (int i = 0; i < 1000; i++) { TreeViewItem itemLevel1 = new TreeViewItem() { Header = "Item Level 1" }; itemLevel1.Items.Add(new TreeViewItem()); rootItem.Items.Add(itemLevel1); }
Update:
You can use the DevExpress TreeList control . This is a free trial.
Or control Telerik TreeView . This is a 30 day free trial. Watch their demo and you can even download and try them.
Update1:
If you have any doubts about Josh Smith's TreeView performance, then I can say about my experience:
- I have 500 nodes and the time to load these elements is 0.0003982 seconds.
- I can scroll up and scroll down and there is no freezing interface ( perfect data virtualization )
- Nested nodes are perfectly open since Josh Smith uses Lazy Loading
- All nodes can have templates. Thus, you can set any image or design that you need.
- This
TreeView
does not completely violate the MVVM rules, so it uses viewModels
for TreeViewItems
. This means that you will not encounter strange errors or exceptions if you had a TreeViewITem
in your viewModel
. For example, this error .
In conclusion, I would like to say that I am very glad that I chose TreeView by JoshSmith
in my production application, because it is very easy to maintain and edit. This is really great performance.
Photo of my TreeView
:

source share