Learn XAMARIN-MAUI with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
Xamarin / .NET MAUI Simple Todo App
// MainPage.xaml.cs
using System.Collections.ObjectModel;
using Microsoft.Maui.Controls;
namespace TodoApp
{
public partial class MainPage : ContentPage
{
ObservableCollection<string> todos = new ObservableCollection<string>();
public MainPage()
{
InitializeComponent();
TodoList.ItemsSource = todos;
}
void AddTodo_Clicked(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(TodoEntry.Text))
{
todos.Add(TodoEntry.Text);
TodoEntry.Text = string.Empty;
}
}
}
}
// MainPage.xaml
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TodoApp.MainPage">
<StackLayout Padding="20">
<Entry x:Name="TodoEntry" Placeholder="New Todo" />
<Button Text="Add" Clicked="AddTodo_Clicked" />
<ListView x:Name="TodoList" />
</StackLayout>
</ContentPage>
Demonstrates a simple Xamarin / .NET MAUI app with a Todo list, adding tasks via UI, and displaying them in a ListView.