[WPF] WPF Data Virtualization and UI Virtualization

Source: Internet
Author: User

This blog will cover virtualization technologies in WPF.

1. Data virtualization Typically, we say that virtualization means that the data source is not fully loaded, loading only the data that is currently needed for display to the user. This scenario reminds us of the data paging display, which requests the data based on the number of pages when the data for a particular page is needed.

WPF did not provide support for the data virtualization primitive ecosystem, which we could have implemented using paging-related technologies. This is described in my previous blog WPF implementation Datagrid/listview pagination control.

2. UI virtualization is an optimization that renders data items for data containers. For example, there are 10,000 item in a Listview/listbox control, but only 10 visible, then only 10 item is rendered and displayed, and the remaining 9,990 item is not instantiated and displayed. This can improve the performance of the program.

The VirtualizingStackPanel container in WPF is the container that implements the UI virtualization, and VirtualizingStackPanel is also the default data container for Listbox/listview.

Here's an example of the impact of turning on UI virtualization and turning off UI virtualization on program performance.

<x:name= "Virtualizationlistview"             Virtualizingpanel.virtualizationmode= "Recycling"          virtualizingpanel.isvirtualizing = "True"  />
 PublicMainWindow () {InitializeComponent ();  This. Loaded + =Delegate{List<string> items =Newlist<string>();  for(inti =0; I <10000; i++) {items. ADD (string. Concat ("Item", i)); }         This. Virtualizationlistview.itemssource =items; };}

At this point, when scrolling through ScrollBar, the memory fluctuation is not obvious.

Virtualizingpanel.virtualizationmode= "Recycling" means that the new item is not looped, such as item1--item20 visible at this time, dragging the scrollbar to Item100, When returning from Item100 to ITEM1--ITEM20, the ITEM1--ITEM20 is not instantiated again. By default virtualizingpanel.virtualizationmode= "standard". When the ListView is scrolling, the memory is incremented.

When UI virtualization is turned off, memory changes are significant, as the program initializes all of the 10,000 data in the ListView.

When encountering the above scenario, it is reasonable to use virtualization technology to improve the performance of the program.

Thank you for reading.

[WPF] WPF Data Virtualization and UI Virtualization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.