Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-improve-the-performance-of-a-treeview.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.0 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Improve the Performance of a TreeView 03/30/2017
csharp
vb
TreeView control [WPF], improving the performance
b792c740-cf2b-4da8-8ba8-3d2e5a821874

How to: Improve the Performance of a TreeView

If a xref:System.Windows.Controls.TreeView contains many items, the amount of time it takes to load may cause a significant delay in the user interface. You can improve the load time by setting the VirtualizingStackPanel.IsVirtualizing attached property to true. The UI might also be slow to react when a user scrolls the xref:System.Windows.Controls.TreeView by using the mouse wheel or dragging the thumb of a scrollbar. You can improve the performance of the xref:System.Windows.Controls.TreeView when the user scrolls by setting the VirtualizingStackPanel.VirtualizationMode attached property to xref:System.Windows.Controls.VirtualizationMode.Recycling?displayProperty=nameWithType.

Example

Description

The following example creates a xref:System.Windows.Controls.TreeView that sets the VirtualizingStackPanel.IsVirtualizing attached property to true and the VirtualizingStackPanel.VirtualizationMode attached property to xref:System.Windows.Controls.VirtualizationMode.Recycling?displayProperty=nameWithType to optimize its performance.

Code

[!code-xamlRecycleItemContainerShippets#VirtualizingTreeView]

The following example shows the data that the previous example uses.

[!code-csharpRecycleItemContainerShippets#TreeViewData] [!code-vbRecycleItemContainerShippets#TreeViewData]

See also