This is a mirror of official site: http://jasper-net.blogspot.com/

ListBox Paging in Silverlight 4 using DataPager control

| Tuesday, April 5, 2011
Prior to Silverlight 4, implementing paging in an application would require the developer to create controls, that would allow the user to move from one page to another. Check an old article by Malcolm Efficient Paging In Silverlight 2.0 which shows how to create and consume a WCF service in Silverlight 2.0 and use efficient server side paging using LINQ to page through event log data.

With the introduction of DataPager control in Silverlight 4, this task has become much simpler. All you need to do is add the DataPager to your page, configure a few properties and use it with the PagedCollectionView.

The DataPager control is a fully templatable data control that provides a user interface for paging through a collection of data. To provide paging functionality for an IEnumerable collection, you can wrap it in the PagedCollectionView class.

Let us see a demonstration of how to use the DataPager control to page through a ListBox control in Silverlight.

Step 1: Create a Silverlight 4 project. Drag and drop a ListBox and DataPager control from the toolbox to the UI.

Step 2: In the MainPage.xaml.cs, add an Employee class as shown below:

employeeclass0327.png

Step 3: Now create the PagedCollectionView using the Employee class we just created in Step 2, and assign it to the DataContext of the MainPage. Observe how we are providing paging functionality for an IEnumerable collection, by wrapping it in the PagedCollectionView class.

pagedcollectionview0327.png

Read more: dot net curry

Posted via email from Jasper-net

0 comments: