📱 .NET MAUI

Create cross-platform native applications for iOS, Android, macOS, and Windows with .NET MAUI.

What is .NET MAUI?

.NET Multi-platform App UI (.NET MAUI) is a framework for building native, cross-platform mobile and desktop apps with C# and XAML. It's the evolution of Xamarin.Forms, extended to support desktop scenarios.

Supported Platforms

Creating Your First MAUI App

# Create a new MAUI application dotnet new maui -n MyMauiApp # Navigate to the project cd MyMauiApp # Build and run on Windows dotnet build -t:Run -f net8.0-windows10.0.19041.0

XAML UI Definition

Define your UI with XAML:

<?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="MyMauiApp.MainPage"> <VerticalStackLayout Spacing="25" Padding="30"> <Label Text="Welcome to .NET MAUI!" FontSize="32" HorizontalOptions="Center" /> <Entry x:Name="NameEntry" Placeholder="Enter your name" /> <Button Text="Say Hello" Clicked="OnButtonClicked" /> <Label x:Name="ResultLabel" FontSize="18" /> </VerticalStackLayout> </ContentPage>

Code-Behind

public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } private void OnButtonClicked(object sender, EventArgs e) { var name = NameEntry.Text; ResultLabel.Text = string.IsNullOrEmpty(name) ? "Hello, World!" : $"Hello, {name}!"; } }

MVVM Pattern

Use the CommunityToolkit.Mvvm for clean architecture:

public partial class MainViewModel : ObservableObject { [ObservableProperty] private string name = string.Empty; [ObservableProperty] private string greeting = string.Empty; [RelayCommand] private void SayHello() { Greeting = string.IsNullOrEmpty(Name) ? "Hello, World!" : $"Hello, {Name}!"; } }

Next Steps

← Back to Developer Resources