.NET MAUI Overview

Build native, cross-platform apps with a single codebase.

Welcome to the official Microsoft documentation for .NET MAUI (Multi-platform App UI). .NET MAUI is an open-source, cross-platform framework for creating native mobile and desktop applications with C# and XAML from a single shared codebase.

Android iOS Windows macOS

What is .NET MAUI?

.NET MAUI is the evolution of Xamarin.Forms. It allows developers to build modern, performant, and visually appealing applications for:

It provides a unified API that abstracts away the underlying platform-specific UI elements, enabling you to write your UI and application logic once and deploy it everywhere.

Key Features

Getting Started

To start building .NET MAUI applications, you'll need to install the .NET SDK and the .NET MAUI workload. The easiest way to get started is by using Visual Studio.

Prerequisites:

Once installed, you can create a new .NET MAUI project directly from Visual Studio's project templates. For command-line development, you can use the dotnet new maui command.

Basic Project Structure:

A typical .NET MAUI project includes:

Example: A Simple Button

Here's a basic XAML example to display a button:

<?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"
             Title="Welcome">

    <ScrollView>
        <VerticalStackLayout
            Padding="30,0"
            Spacing="25"
            VerticalOptions="Center">

            <Image
                Source="dotnet_bot.png"
                HeightRequest="200"
                HorizontalOptions="Center" />

            <Label
                Text="Hello, .NET MAUI!"
                SemanticProperties.HeadingLevel="Level1"
                FontSize="32"
                HorizontalOptions="Center" />

            <Button
                x:Name="CounterBtn"
                Text="Click me"
                SemanticProperties.Hint="Counts the number of times you click"
                Clicked="OnCounterClicked"
                HorizontalOptions="Center" />

        </VerticalStackLayout>
    </ScrollView>

</ContentPage>

And the corresponding C# code-behind:

using Microsoft.Maui.Controls;
using System;

namespace MyMauiApp
{
    public partial class MainPage : ContentPage
    {
        int count = 0;

        public MainPage()
        {
            InitializeComponent();
        }

        private void OnCounterClicked(object sender, EventArgs e)
        {
            count++;
            CounterBtn.Text = $"Clicked {count} times";
        }
    }
}

Learn More

Explore the following resources to deepen your understanding of .NET MAUI:

This documentation provides a comprehensive guide to developing cross-platform applications with .NET MAUI. Dive in and start building!