Build a .NET MAUI 11 app, then test the bits that usually break

Build a small C# checklist for phone and desktop, then test navigation, validation, layout and a Release build—not just the sample button.

By George the bot

Edited and approved by Faysal Aziz

Published

Classic-comic industrial app press sending a small interface to phone and desktop conveyors, with a warning lamp and inspection gauge for edge-case testing. Official .NET wordmark on the press.
Original editorial illustration; official .NET wordmark from the dotnet/brand repository. Independent tutorial; not affiliated with or endorsed by Microsoft.

A shared C# codebase sounds lovely until a page behaves differently on a phone, a desktop window, and a Release build. Microsoft .NET MAUI 11 is a good excuse to learn the whole loop rather than stop when the sample button works: create a tiny app, change its XAML, navigate between pages, and test the awkward edges.

The project here is a maintenance checklist. You type a task, add it to an on-screen list, and open an About page. It is intentionally small. There is no account, sync service or database to hide the UI mechanics. By the end you should be able to identify which code is shared, which platform tooling is still required, and what a Debug-only success does not prove.

1. Set up the target you can actually run

Install the .NET 11 SDK and the .NET MAUI workload through a supported Visual Studio or Visual Studio Code setup. Verify the SDK and workload before creating the project:

dotnet --version
dotnet workload list

Create a project with the MAUI app template and inspect its target frameworks in WorkshopCheck.csproj:

dotnet new maui -n WorkshopCheck
cd WorkshopCheck

The template and installed workloads must support .NET 11. On Windows, begin with Windows or an Android emulator. On macOS, begin with Mac Catalyst or an iOS/Android simulator. Apple builds require a Mac with the appropriate Xcode installation; one codebase does not remove that platform requirement. A Windows-only machine can still build and test the Windows and Android versions without pretending it has tested iOS.

Keep the generated App.xaml, App.xaml.cs, MauiProgram.cs and platform folders. We will replace AppShell.xaml and MainPage.xaml, edit MainPage.xaml.cs, and add one AboutPage.cs. If you chose a different project name, replace the WorkshopCheck namespace in the snippets.

2. Make the shared interface in XAML

Replace AppShell.xaml with two explicit routes. The first is the checklist; the second is the About page. Explicit route names matter because generated ones are not guaranteed to stay stable across launches.

<?xml version="1.0" encoding="UTF-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:local="clr-namespace:WorkshopCheck"
       x:Class="WorkshopCheck.AppShell"
       FlyoutBehavior="Disabled">
    <ShellContent Title="Checklist" Route="checklist"
                  ContentTemplate="{DataTemplate local:MainPage}" />
    <ShellContent Title="About" Route="about"
                  ContentTemplate="{DataTemplate local:AboutPage}" />
</Shell>

Now replace MainPage.xaml. Its CollectionView reads the collection that we will expose from the page class. The named Entry gives the click handler the current text, while the AutomationId values make the important controls easier to find in UI tests.

<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="WorkshopCheck.MainPage"
             Title="Checklist">
    <Grid Padding="24" RowDefinitions="Auto,Auto,*,Auto" RowSpacing="16">
        <Label Grid.Row="0" Text="Workshop checklist"
               FontSize="28" FontAttributes="Bold" />
        <HorizontalStackLayout Grid.Row="1" Spacing="8">
            <Entry x:Name="TaskEntry" AutomationId="task-entry"
                   Placeholder="e.g. Check the cooling fan"
                   HorizontalOptions="FillAndExpand" />
            <Button Text="Add" AutomationId="add-task"
                    Clicked="OnAddClicked" />
        </HorizontalStackLayout>
        <CollectionView Grid.Row="2" ItemsSource="{Binding Tasks}"
                        AutomationId="task-list">
            <CollectionView.EmptyView>
                <Label Text="No tasks yet. Add one above."
                       VerticalOptions="Center" HorizontalOptions="Center" />
            </CollectionView.EmptyView>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Label Text="{Binding .}" Padding="12"
                           FontSize="18" />
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
        <Button Grid.Row="3" Text="About this app"
                AutomationId="about-button" Clicked="OnAboutClicked" />
    </Grid>
</ContentPage>

This is not a claim that the same pixels will look identical on every system. Native controls and input methods differ. The useful commonality is the page structure and shared behavior; test the actual target's keyboard, scaling and screen size.

3. Add behavior and navigation

Replace MainPage.xaml.cs with the following. ObservableCollection notifies the list when an item arrives. Trimming the input prevents whitespace-only entries, and clearing the box makes the next entry obvious. This sample keeps tasks in memory only: close the app and the list resets. Persistence is a later exercise, not an unmentioned feature.

using System.Collections.ObjectModel;
 
namespace WorkshopCheck;
 
public partial class MainPage : ContentPage
{
    public ObservableCollection<string> Tasks { get; } = new();
 
    public MainPage()
    {
        InitializeComponent();
        BindingContext = this;
    }
 
    private async void OnAddClicked(object sender, EventArgs e)
    {
        string task = TaskEntry.Text?.Trim() ?? string.Empty;
        if (task.Length == 0)
        {
            await DisplayAlert("Nothing to add", "Enter a task first.", "OK");
            return;
        }
 
        Tasks.Add(task);
        TaskEntry.Text = string.Empty;
    }
 
    private async void OnAboutClicked(object sender, EventArgs e)
    {
        await Shell.Current.GoToAsync("//about");
    }
}

Add AboutPage.cs beside MainPage.xaml.cs:

namespace WorkshopCheck;
 
public sealed class AboutPage : ContentPage
{
    public AboutPage()
    {
        Title = "About";
        Content = new VerticalStackLayout
        {
            Padding = new Thickness(24),
            Spacing = 16,
            Children =
            {
                new Label { Text = "Workshop Check", FontSize = 28 },
                new Label { Text = "A small .NET MAUI checklist for learning UI and navigation." }
            }
        };
    }
}

Run the project on your first chosen target. Add Check the cooling fan, open About, then return to Checklist using the visible Shell navigation. Notice that switching between Shell sections can recreate page instances; do not mistake this in-memory collection for durable storage. If your real app must survive navigation or restart, move state into a shared service and persist it deliberately.

4. Use Hot Reload as a fast feedback loop, not a release test

In a Debug session, change the heading text or a colour in MainPage.xaml and observe XAML Hot Reload. .NET MAUI 11's incremental XAML Hot Reload is still a preview feature. It can patch live controls without rebuilding the page, but it does not establish that every XAML change or platform behavior is correct. If the updated view looks stale, save the file, check whether Hot Reload reported an error, and do a clean run. If an extension or custom control behaves oddly, try the same change without relying on Hot Reload before blaming your page code.

CoreCLR is the default runtime for .NET 11 MAUI apps across the supported platforms. That is a meaningful platform change, but do not treat Microsoft's build/startup numbers as a prediction for this tiny app. Native AOT is a separate opt-in publishing path, with Android support still experimental; leave it off for this first exercise.

5. Test beyond the happy path

Use at least two target shapes, such as an Android emulator and a Windows desktop window, when your machine supports them. Record the device/OS and build configuration with each result. Work through this small matrix:

• Launch with an empty list. The empty-state message should be visible and no exception should appear.

• Tap Add with empty text, then with spaces only. Both should show the validation message and leave the list unchanged.

• Add a normal task and a long task. Check clipping, wrapping and scrolling at a narrow phone width and in a resized desktop window.

• Open About and return. Check the route works, the back/navigation affordance makes sense, and the checklist state behaves as expected for this deliberately in-memory sample.

• Increase system text size or display scaling. Check that the Entry, button and list remain usable; a layout that works at default settings may fail here.

• Try touch and keyboard input where available. In particular, verify the software keyboard does not hide the Add control.

Do not turn “it compiled” into “cross-platform verified.” If iOS was not available, say so in the test notes. That is a better result than assuming the Android run covered it.

6. Build the version you would actually ship

First make a Release build for a target framework that appears in your project file. For Android, for example:

dotnet build -f net11.0-android -c Release

Then run or install the Release build on a device or emulator and repeat the validation, navigation, large-text and narrow-width checks. Debug and Release can differ because of optimization, trimming and runtime packaging. A successful Release build is not yet a store-ready package: Android signing, Apple provisioning and distribution-specific settings are additional steps. Follow the official publishing instructions for the platform you intend to ship.

If you are upgrading an existing MAUI app instead of starting fresh, check its NuGet dependencies and custom handlers before changing the target framework. .NET MAUI 11 raises Android's minimum to API 24, removes the optional Microsoft.Maui.Controls.Compatibility package, changes some navigation handlers, and moves Apple minimum versions upward. Test your actual oldest supported device. A library that relies on reflection, old renderers or timing around Appearing deserves particular attention. Incremental Hot Reload will not catch those release and compatibility problems for you.

The skill worth keeping is this loop: make one UI change, run it on a real target, exercise an edge case, then check the Release artifact. It transfers to more ambitious MAUI apps far better than memorising a list of new controls.

Sources