Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syncfusionexamples/xamarin.forms-listview-paging
Example showcases how to do paging in Xamarin.Forms Listview using DataPager.
https://github.com/syncfusionexamples/xamarin.forms-listview-paging
datapager listview paging sflistview xamarin xamarin-android xamarin-forms xamarin-ios xamarin-listview xamarin-uwp
Last synced: 7 days ago
JSON representation
Example showcases how to do paging in Xamarin.Forms Listview using DataPager.
- Host: GitHub
- URL: https://github.com/syncfusionexamples/xamarin.forms-listview-paging
- Owner: SyncfusionExamples
- Created: 2019-08-02T05:47:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-15T13:47:19.000Z (10 months ago)
- Last Synced: 2024-04-14T12:07:22.726Z (8 months ago)
- Topics: datapager, listview, paging, sflistview, xamarin, xamarin-android, xamarin-forms, xamarin-ios, xamarin-listview, xamarin-uwp
- Language: C#
- Homepage:
- Size: 915 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Paging in Xamarin.Forms Listview
The SfListView allows displaying paging using the [SfDataPager](http://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfDataGrid.XForms~Syncfusion.SfDataGrid.XForms.DataPager_namespace.html) control. It can be performed through loading data dynamically into ItemsSource of the SfListView using OnDemandLoading event for the current page by setting the [SfDataPager.UseOnDemandPaging](http://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfDataGrid.XForms~Syncfusion.SfDataGrid.XForms.DataPager.SfDataPager~UseOnDemandPaging.html) to `True`. By using the [SfDataPager.PageSize](http://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfDataGrid.XForms~Syncfusion.SfDataGrid.XForms.DataPager.SfDataPager~PageSize.html) property, you can define the number of list items to be displayed in each page.
```
```
```
public class SfListViewPagingBehavior : Behavior
{private Syncfusion.ListView.XForms.SfListView listView;
private PagingViewModel PagingViewModel;
private SfDataPager dataPager;protected override void OnAttachedTo(ContentPage bindable)
{
listView = bindable.FindByName("listView");
dataPager = bindable.FindByName("dataPager");
PagingViewModel = new PagingViewModel();
listView.BindingContext = PagingViewModel;
dataPager.Source = PagingViewModel.pagingProducts;
dataPager.OnDemandLoading += DataPager_OnDemandLoading;
base.OnAttachedTo(bindable);
}private void DataPager_OnDemandLoading(object sender, OnDemandLoadingEventArgs e)
{
var source = PagingViewModel.pagingProducts.Skip(e.StartIndex).Take(e.PageSize);
listView.ItemsSource = source.AsEnumerable();
}protected override void OnDetachingFrom(ContentPage bindable)
{
listView = null;
PagingViewModel = null;
dataPager = null;
base.OnDetachingFrom(bindable);
}
}
```
To know more about MVVM in ListView, please refer our documentation [here](https://help.syncfusion.com/xamarin/sflistview/mvvm)