MAUI projects and platform targets
MAUI projects and platform targets
.NET MAUI builds native-control applications from shared .NET code plus target-specific assets and startup code. A project can target Android, iOS, Windows and macOS through Mac Catalyst, but a shared codebase does not make every API, OS requirement or device behavior identical.
A MAUI single project contains target frameworks, shared pages and models, Resources and Platforms folders. The selected workload supplies platform SDK integration; target builds may require Android SDK/JDK, Xcode and Apple hardware or Windows tooling. Inspect the approved workload, template and supported OS matrix before building. .NET 10 LTS does not imply the same support period for MAUI 10: MAUI follows its own servicing policy. The documentation snapshots retrieved for this batch disagree about freshness, so no latest MAUI patch is asserted. MauiProgram creates the builder and registers services; App creates a Window; Shell or another root page hosts navigation. Handlers connect shared controls to native implementations. XAML declares layout and bindings; x:DataType helps compile binding paths. Native MAUI controls differ from MAUI Blazor Hybrid, which embeds Razor components in a native WebView, and from a browser-only web app. Use injected interfaces for device-specific capabilities and test shared validation without hardware. The overlays below replace named source files in a fresh MAUI template, not an already existing app.
Baseline: .NET 10 / C# 14. Every expected result is reasoned, not executed. The complete portable and Windows desktop projects are separate from MAUI template overlays. No runtime or UI claims.
Create a native notes page
Use an approved .NET 10 MAUI template named Fixture. Replace the specified page files, keep the platform entry points and resources.
In an approved environment with .NET 10 SDK and MAUI 10 workload already available, create a fresh disposable standard MAUI app with dotnet new maui -n Fixture -o Fixture --no-restore. Confirm namespace Fixture, standard Shell root, target framework, resource paths, and actual template compatibility; stop on mismatch. Copy the archived Program.cs AS MainPage.xaml.cs (replace, do not add a duplicate). Replace MainPage.xaml and any named companion in the generated project. Keep the template project, platform startup and assets. Inspect dependency graph and target tooling before approved restore/build; use the actual target framework from the template. Run only on an authorized emulator or disposable device. No silent installation, signing, or publishing.
using System;using Microsoft.Maui.Controls;using Microsoft.Maui;namespace Fixture;public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } private void Preview(object? sender, EventArgs e) { string note = Input.Text?.Trim() ?? ""; Result.Text = note.Length is >0 and <=40 ? $"Preview: {note}" : "Enter 1 to 40 characters"; }}MainPage.xaml
<ContentPage x:Class="Fixture.MainPage" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" Title="Notes lab"> <ScrollView> <VerticalStackLayout Padding="20" Spacing="12"> <Label Text="Note"/> <Entry x:Name="Input" Placeholder="Synthetic note" SemanticProperties.Description="Note text"/> <Button Text="Preview" Clicked="Preview"/> <Label x:Name="Result" Text="Not submitted"/> </VerticalStackLayout> </ScrollView></ContentPage>Expected result (not executed):
Blank: Enter 1 to 40 characters. Atlas: Preview: Atlas.The same shared event code uses native controls on supported targets. Verify font scaling, keyboard behavior and rendering independently.
Bind a typed view model
The fixture uses a compiled binding for a read-only display value. Change the model initialization and rebuild.
In an approved environment with .NET 10 SDK and MAUI 10 workload already available, create a fresh disposable standard MAUI app with dotnet new maui -n Fixture -o Fixture --no-restore. Confirm namespace Fixture, standard Shell root, target framework, resource paths, and actual template compatibility; stop on mismatch. Copy the archived Program.cs AS MainPage.xaml.cs (replace, do not add a duplicate). Replace MainPage.xaml and any named companion in the generated project. Keep the template project, platform startup and assets. Inspect dependency graph and target tooling before approved restore/build; use the actual target framework from the template. Run only on an authorized emulator or disposable device. No silent installation, signing, or publishing.
using System;using Microsoft.Maui.Controls;using Microsoft.Maui;namespace Fixture;public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); BindingContext = new NoteViewModel("Atlas"); }}public sealed class NoteViewModel(string title) { public string Title { get; } = title;}MainPage.xaml
<ContentPage x:Class="Fixture.MainPage" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" Title="Notes lab"> <VerticalStackLayout Padding="20" Spacing="12" xmlns:local="clr-namespace:Fixture" x:DataType="local:NoteViewModel"> <Label Text="Selected note" SemanticProperties.HeadingLevel="Level1"/> <Label Text="{Binding Title, Mode=OneWay}"/> </VerticalStackLayout></ContentPage>Expected result (not executed):
Selected note / Atlas.x:DataType declares the expected binding source type; BindingContext supplies the instance. This immutable property needs no change notification.
Keep validation independent of device APIs
Run shared code with synthetic input without a MAUI workload.
Use the complete Fixture.csproj with an approved .NET 10 SDK. Restore approved dependencies, build and run. No UI workload needed.
using System;foreach(var raw in new[]{" Atlas ","",new string('x',41)}) { var result=Normalize(raw); Console.WriteLine(result ?? "Rejected");}static string? Normalize(string raw) { string value=raw.Trim(); return value.Length is >0 and <=40 ? value : null;}Expected result (not executed):
AtlasRejectedRejectedPortable validation does not depend on device permissions or handlers. The 40 limit counts UTF-16 units.
Apply the concept
Design an offline note app targeting Android and Windows. Draw the shared model, UI page, storage interface and platform adapter boundaries. List the tooling evidence needed before building.
Use the manual practice and knowledge check. Do not deploy or publish these fixtures.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
MAUI projects and platform targets — knowledge check
Apply the lesson concepts to the following scenarios.
What is a MAUI handler responsible for?
What is x:DataType used for in a binding scope?
Does .NET 10 LTS guarantee the same MAUI support period?
What should remain from the reviewed fresh template when applying a page overlay?
Which test can run without a mobile UI workload?