.NET MAUI Documentation

Build native cross-platform apps with a single codebase.

Getting Started with .NET MAUI

This guide will walk you through the essential steps to set up your development environment and create your first .NET MAUI application.

Prerequisites

Before you begin, ensure you have the following installed:

  • Visual Studio 2022 version 17.3 or later with the ".NET Multi-platform App UI development" workload.
  • .NET 6 SDK (or later).

For detailed installation instructions, please refer to the Visual Studio Installation Guide.

Step 1: Install the .NET MAUI Workload

If you haven't already, open the Visual Studio Installer and select the ".NET Multi-platform App UI development" workload. This will install all the necessary components for .NET MAUI development.

Visual Studio Installer with MAUI workload highlighted

Step 2: Create a New .NET MAUI Project

Once Visual Studio is set up, you can create a new project:

  1. Open Visual Studio.
  2. Click "Create a new project".
  3. Search for ".NET MAUI".
  4. Select the " .NET MAUI App" template and click "Next".
  5. Enter your project name (e.g., "MyFirstMauiApp") and location, then click "Next".
  6. Select the target framework (.NET 6 recommended) and click "Create".

Step 3: Explore Your Project

A new .NET MAUI project contains several key folders and files:

  • Platforms: Contains platform-specific code (Android, iOS, macOS, Windows).
  • Resources: Holds application resources like images, fonts, and styles.
  • App.xaml: The main application file.
  • AppShell.xaml: Defines the application's shell (navigation structure).
  • MainPage.xaml: The starting page of your application.
  • MainPage.xaml.cs: The code-behind file for MainPage.

Example: Modifying MainPage.xaml

Open MainPage.xaml and locate the Label control. You can change its text property:

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

Similarly, you can modify the corresponding code-behind file, MainPage.xaml.cs, to add logic.

Step 4: Run Your Application

You can now run your application on a simulator or a physical device:

  1. In Visual Studio, select your desired target platform (e.g., Android Emulator, Windows Machine) from the dropdown menu.
  2. Click the "Run" button (the green triangle).

Your first .NET MAUI app should now be running!

Next Steps

Now that you have a basic understanding of how to set up and run a .NET MAUI app, you can dive deeper into: