Overview
.NET Multi-platform App UI (MAUI) is Microsoft’s cross‑platform framework for building native mobile, desktop, and wearable apps with a single shared codebase.
MAUI extends Xamarin.Forms, providing a unified project structure, modern tooling, and native performance on Android, iOS, macOS, and Windows.
dotnet new maui -n MyMauiApp
cd MyMauiApp
dotnet build
dotnet run
Getting Started
- Install the
.NET 8 SDK
and Visual Studio 2022 (or later) with the MAUI workload. - Create a new MAUI project using the CLI or the VS template.
- Explore
MainPage.xaml
– the entry point UI. - Run on a simulator/emulator or a connected device.
Example MainPage.xaml
:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyMauiApp.MainPage">
<VerticalStackLayout Spacing="25" Padding="30">
<Label Text="Welcome to .NET MAUI!"
FontSize="32"
HorizontalOptions="Center" />
<Button Text="Click me"
Clicked="OnButtonClicked"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>
Architecture
MAUI follows a layered architecture:
- Presentation Layer – XAML UI and code‑behind.
- Business Logic – ViewModels (MVVM) using
INotifyPropertyChanged
. - Platform Services – Dependency injection for native APIs.
- Core – .NET Standard libraries shared across platforms.
Dependency Injection example:
builder.Services.AddSingleton<IDataService, DataService>();
Controls
MAUI provides a rich set of cross‑platform controls. Below are a few frequently used ones.
Control | Description |
---|---|
Label | Displays static text. |
Button | Triggers actions. |
Entry | Single‑line text input. |
CollectionView | Efficient list rendering. |
Shell | App navigation and layout. |
Sample CollectionView
:
<CollectionView ItemsSource="{Binding Items}">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Padding="10">
<Label Text="{Binding Title}" FontAttributes="Bold"/>
<Label Text="{Binding Description}" FontSize="Small"/>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Data Binding
MAUI uses XAML data binding to connect UI elements to ViewModels.
public class MainViewModel : INotifyPropertyChanged
{
private string _greeting = "Hello, MAUI!";
public string Greeting
{
get => _greeting;
set { _greeting = value; OnPropertyChanged(); }
}
public ICommand ClickCommand => new Command(() => Greeting = "Button clicked!");
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null) =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
Binding in XAML:
<Label Text="{Binding Greeting}" FontSize="24" HorizontalOptions="Center"/>
<Button Text="Tap me" Command="{Binding ClickCommand}" />
Deployment
MAUI apps can be packaged for each platform using the same command line:
# Android
dotnet build -t:Run -f net8.0-android
# iOS (macOS host)
dotnet build -t:Run -f net8.0-ios
# macOS
dotnet build -t:Run -f net8.0-maccatalyst
# Windows
dotnet run -f net8.0-windows
Publishing to app stores requires platform‑specific signing certificates and store metadata. Refer to the official deployment guide for detailed steps.