Thre links provided in the previous answer contain the information to answer this question. Also, James has a great set of YT videos dedicated to MAUI. I highly recommend that you read the material and watch his videos:
.NET MAUI Tutorial for Beginners - Build iOS, Android, macOS, & Windows Apps with C# & Visual Studio - YouTube[
^]
However, here is an example of what you are trying to do:
1. Code-Behind - same as previous example, however using a collection of objects:
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
BindingContext = this;
}
public ObservableCollection<Person> Names { get; set; } = new ObservableCollection<Person>
{
new Person { FirstName = "Freddie", LastName = "Kruger" },
new Person { FirstName = "Jason", LastName = "Voorhees" },
new Person { FirstName = "Norman", LastName = "Bates" },
new Person { FirstName = "Hannibal", LastName = "Lecter" },
new Person { FirstName = "Damien", LastName = "Thorn" },
};
}
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
2. The XAML:
="1.0"="utf-8"
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage">
<ListView ItemsSource="{Binding Names}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Text="{Binding FirstName}"
Grid.Column="0"/>
<Label Text="{Binding LastName}"
Grid.Column="1"
Padding="10,0"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>