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

.NET MAUI DataGrid LoadMoreData Command

Updated on Sep 28, 2026

The LoadMoreData command is another alternative for loading data on demand. This alternative is suitable for MVVM scenarios.

Example

The following example demonstrates a sample setup that shows how to use the command:

  1. Define the DataGrid in XAML:
XAML
<telerik:RadDataGrid x:Name="dataGrid"
                     ItemsSource="{Binding Items}"
                     LoadOnDemandMode="Automatic"
                     LoadOnDemandBufferItemsCount="{Binding Source={x:Reference slider}, Path=Value}"/>
  1. Add the telerik namespace:
xaml
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
  1. Add sample data:
C#
public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    public Gender Gender { get; set; }
}
  1. Define the ViewModel:
C#
public class LoadMoreDataCommandViewModel
{
    public LoadMoreDataCommandViewModel()
    {
        this.Items = new ObservableCollection<Person>();

        for (int i = 0; i < 20; i++)
        {
            var person = new Person { Name = "Person " + i, Age = i + 18, Gender = i % 2 == 0 ? Gender.Male : Gender.Female };
            this.Items.Add(person);
        }
    }

    public ObservableCollection<Person> Items { get; set; }
}
  1. Create the custom command:
C#
public class CustomLoadMoreDataCommand : DataGridCommand
{
    public CustomLoadMoreDataCommand()
    {
        this.Id = DataGridCommandId.LoadMoreData;
    }

    public override bool CanExecute(object parameter)
    {
        return true;
    }

    public async override void Execute(object parameter)
    {
        if (parameter == null)
        {
            return;
        }

        ((LoadOnDemandContext)parameter).ShowLoadOnDemandLoadingIndicator();
        
        await System.Threading.Tasks.Task.Delay(1500);
        var viewModel = this.Owner.BindingContext as LoadMoreDataCommandViewModel;
        if (viewModel != null)
        {
            for (int i = 0; i < 10; i++)
            {
                viewModel.Items.Add(new Person { Name = "Person " + i, Age = i + 18, Gender = i % 2 == 0 ? Gender.Male : Gender.Female });
            }
        }
        ((LoadOnDemandContext)parameter).HideLoadOnDemandLoadingIndicator();
    }
}

Invoking the ShowLoadOnDemandLoadingIndicator and HideLoadOnDemandLoadingIndicators methods is required. Without calling these methods, the BusyIndicator used for the functionality is not visualized.

  1. Add the custom command to the Commands collection of the DataGrid:
C#
this.dataGrid.Commands.Add(new CustomLoadMoreDataCommand());

For DataGrid LoadMoreData command example, refer to the SDKBrowser Demo application and go to the DataGrid > LoadOnDemand category.

See Also

In this article
ExampleSee Also
Not finding the help you need?
Contact Support