Getting Started

This guide provides the information you need to start using the Telerik UI for .NET MAUI ListView by adding the control to your project.

At the end, you will be able to achieve the following result.

RadListView

Prerequisites

Before adding the ListView, you need to:

  1. Set up your .NET MAUI application.

  2. Download Telerik UI for .NET MAUI.

  3. Install Telerik UI for .NET MAUI.

Define the Control

When your .NET MAUI application is set up, you are ready to add a ListView control to your page. The following example shows a sample ListView definition populated with sample data.

The ListView provides UI virtualization, which requires the visual parent to provide vertical or horizontal space. To avoid breaking UI virtualization or gesture mechanisms:

  • Do not place the ListView inside a StackLayout or inside a ScrollView.
  • Do not set the ListVew to a RowDefinition Height="Auto" Grid definition.

Set up the RadListView instance:

<telerik:RadListView x:Name="listView" ItemsSource="{Binding Source}">
    <telerik:RadListView.BindingContext>
        <local:ViewModel />
    </telerik:RadListView.BindingContext>
    <telerik:RadListView.ItemTemplate>
        <DataTemplate>
            <telerik:ListViewTemplateCell>
                <telerik:ListViewTemplateCell.View>
                    <Grid>
                        <Label Margin="10" Text="{Binding Name}" />
                    </Grid>
                </telerik:ListViewTemplateCell.View>
            </telerik:ListViewTemplateCell>
        </DataTemplate>
    </telerik:RadListView.ItemTemplate>
</telerik:RadListView>

Add the telerik namespaces:

xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"

Let's create sample Data and ViewModel classes:

public class SourceItem
{
    public SourceItem(string name)
    {
        this.Name = name;
    }

    public string Name { get; set; }
}

public class ViewModel
{
    public ViewModel()
    {
        this.Source = new List<SourceItem> 
        {
            new SourceItem("Tom"),
            new SourceItem("Anna"), 
            new SourceItem("Peter"), 
            new SourceItem("Teodor"), 
            new SourceItem("Lorenzo"), 
            new SourceItem("Andrea"), 
            new SourceItem("Jeremy"), 
            new SourceItem("Linda"), 
            new SourceItem("Mario"), 
            new SourceItem("Alex"), 
            new SourceItem("Barbara"), 
            new SourceItem("Nicole"), 
            new SourceItem("Paul"), 
            new SourceItem("Raul"), 
            new SourceItem("Lenny"), 
            new SourceItem("Laura"), 
            new SourceItem("Mike"), 
            new SourceItem("Taylor"), 
            new SourceItem("Martin") 
        };
    }

    public List<SourceItem> Source { get; set; }
}

Register the Telerik controls through the Telerik.Maui.Controls.Compatibility.UseTelerik extension method called inside the CreateMauiApp method of the MauiProgram.cs file of your project:

using Telerik.Maui.Controls.Compatibility;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseTelerik()
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            });

        return builder.Build();
    }
}           

See Also

In this article
Not finding the help you need?