Welcome to .NET MAUI for Desktop

.NET Multi-platform App UI (MAUI) enables developers to create native desktop applications for Windows and macOS using a single shared codebase. This documentation provides comprehensive guidance, from project creation to advanced topics like custom renderers and performance tuning.

Key Concepts

Quick Start

Run the following command to create a new MAUI desktop app:

dotnet new maui -n MyDesktopApp

Navigate to the project folder and launch the app:

cd MyDesktopApp
dotnet build
dotnet run

Sample Code

The MainPage.xaml below demonstrates a simple layout with a button and label:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyDesktopApp.MainPage">
    <StackLayout Padding="30">
        <Label Text="Welcome to .NET MAUI!" 
               FontSize="24"
               HorizontalOptions="Center" />
        <Button Text="Click me"
                Clicked="OnButtonClicked"
                HorizontalOptions="Center" />
    </StackLayout>
</ContentPage>

In MainPage.xaml.cs:

using Microsoft.Maui.Controls;

namespace MyDesktopApp;

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

    public MainPage()
    {
        InitializeComponent();
    }

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