-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Many apps display and manipulate collections of data, like a list of search results or an album of photos. When the collection is very large, performance can be degraded when displaying or manipulating the collection. To improve performance with large data sets, you can use virtualisation.
Windows apps support two types of virtualisation:
- UI virtualisation; and
- Data virtualisation.
When you add an item to an ItemsControl, the item is wrapped in an item container. For example, an item added to a ListView is wrapped in a ListViewItem. Without UI virtualisation, the entire data set is kept in memory and an item container is also created for each item in the data set. A ListView that's bound to a collection of 1000 items will also create 1000 ListViewItem containers that are stored in memory.
With UI virtualization, the data set is still kept in memory, but an item container is created only when the item is nearly ready to be shown in the UI. A ListView using UI virtualization might keep only 20 ListViewItem objects in memory. It creates or re-uses the ListViewItems as needed when the user scrolls through the list. (The number of ListViewItem objects depends on how many items are displayed in the UI.) By default, ItemsControl, and the standard controls derived from it, support UI virtualisation.
With UI virtualisation, the complete data set is stored in memory. Sometimes, your data set is so large that it can't or shouldn't be stored in memory all at once. In this case, you can use data virtualisation to get only a subset of the data to work with. The ItemsControl can still apply UI virtualisation to the subset of data created by data virtualisation.
With incremental data virtualisation, your app downloads data sequentially. For example, if a ListView is bound to a collection of 100,000 items, your app might download only items 1-50. The scroll bar's thumb is sized to represent its position in the initial 50 item data set. When the user scrolls near the end of the list, items 51 – 100 are downloaded. The scroll bar's thumb is resized to represent its position in the updated 100 item data set.
To use incremental data virtualisation, you must use a data source that implements ISupportIncrementalLoading.
Incremental data virtualisation is supported by the ListView and GridView controls.
The IncrementalLoadingCollection<T> is a simple collection designed to facilitate incremental data virtualisation in Windows Universal apps through the implementation of the ISupportIncrementalLoading interface. It is a generic class and is designed to be used in place of an ObservableCollection<T>.
To use the IncrementalLoadingCollection<T> you must provide the class with a data source that is capable of loading data sequentially by implementing the IVirtualisedDataSource<T>.
See Getting Started for details on how to use the IncrementalLoadingCollection<T> in your own apps.
You can find out more about UI and data virtualisation by reading Using virtualization (sic) with a list of grid (XAML) on MSDN.