New to Telerik UI for .NET MAUI? Start a free 30-day trial

.NET MAUI DataPager Data Source Binding

The Telerik UI for .NET MAUI DataPager can page any collection that implements the IEnumerable interface.

To bind the desired collection to the DataPager, pass the collection to the DataPager's Source (object) property. This will split the data into pages.

The following demonstrates how to use the Source property to bind a collection:

1. Define the DataPager in XAML:

<telerik:RadDataPager x:Name="dataPager" Source="{Binding Data}" />

2. Add a sample ViewModel:

public class ViewModel
{
    public ViewModel()
    {
        Data = CreateData(200);
    }

    public List<int> Data { get; set; }

    internal static List<int> CreateData(int count)
    {
        List<int> source = new List<int>();

        for (int i = 0; i < count; i++)
        {
            source.Add(i);
        }

        return source;
    }
}

3. Set the ViewModel as a BindingContext:

this.BindingContext = new ViewModel();

Binding to the PagedSource Property of the RadDataPager

Often, your collection will be a simple List, an ObservableCollection, or a collection that inherits from IEnumerable. Unless you had paging in mind when you designed your project, it is almost certain that your data source will not be pageable out of the box. In these scenarios, bind to the PagedSource (IEnumerable) property of the RadDataPager.

DataPager PagedSource

The image above illustrates the process for binding to the PagedSource property of the DataPager:

  1. You assign an object to the Source of a RadDataPager.
  2. The RadDataPager wraps the Source in a custom collection.
  3. The Source is exposed through the RadDataPager.PagedSource property.
  4. You attach any number of item controls to the PagedSource and they are paged automatically.

Review the Integration with DataGrid article, for more details how to use the PagedSource property.

See Also

In this article