How to implement list-bottom loading in Windows Phone 8

Source: Internet
Author: User

Background

Many times in the process of doing WP development will encounter data needs paging acquisition, according to Microsoft's official recommendation, proposed to achieve a similar experience in market, that is, sliding to the bottom of the list to load more data.

This demand in the early WP7.1 time to realize is very laborious, need to rely on WP Toolkit in the longlistselector, and since the LLS by Microsoft after the need to achieve a more official method.

"The realization of ideas"

LLS inherits the features of the ListBox UI virtualization, where data from UI virtualization--a list data source--does not itemtemplete all data at once, but as the list slides, it is either UI at any time, or the UI data is released. For example, the more intuitive:

For example, the LLS data source has a 1W user type of data, which records users ' information. LLS is responsible for displaying the 1W data. Suppose a screen can display 10. So the job of UI virtualization is to:

1, 30 (for example data) user based on Itemtemplete to draw the corresponding 30 UI controls

2, slide down to see the 20th data, from the data source to take out 20 draw UI control, and the first 20 of the drawing out of the control released.

3, slide down to see the 40th data, and then take out the data source 20 draw UI control, and the first 20 drawn out of the control released.

4, to slide back to the 20th data, reverse again to draw and release

The concept of UI virtualization above is understood and the requirements in our headlines are well implemented.

LLS defines the onitemrealized event, which simply says that when Lls draws a UI control based on Itemtemplete, it triggers this event to notify the user of which data is currently being drawn.

"Specific Code Analysis"

The code we implement according to this definition is as follows:

Explain:

1, offset is the distance from the last item in the data source

2, IsLoading is the dependency property, identity is currently loading data

3. When the Onitemrealized event is triggered, determine whether the current realized item is the penultimate item of the data source, and if so, it is considered necessary to load new data, triggering the Datarequest event

Such a simple universal "endless list" is implemented.

See more highlights of this column: http://www.bianceng.cn/OS/extra/

Reference:

Http://msdn.microsoft.com/library/windowsphone/develop/microsoft.phone.controls.longlistselector.itemrealized ( v=vs.105). aspx

http://code.msdn.microsoft.com/wpapps/TwitterSearch-Windows-b7fc4e5e

See the complete code:

https://gist.github.com/tianhonghui/6999984

Related Article

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.