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:
- Define the DataGrid in XAML:
XAML
<telerik:RadDataGrid x:Name="dataGrid"
ItemsSource="{Binding Items}"
LoadOnDemandMode="Automatic"
LoadOnDemandBufferItemsCount="{Binding Source={x:Reference slider}, Path=Value}"/>
- Add the telerik namespace:
xaml
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
- Add sample data:
C#
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public Gender Gender { get; set; }
}
- 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; }
}
- 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
ShowLoadOnDemandLoadingIndicatorandHideLoadOnDemandLoadingIndicatorsmethods is required. Without calling these methods, theBusyIndicatorused for the functionality is not visualized.
- Add the custom command to the
Commandscollection 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.