MSDN Documentation

.NET MAUI

Getting Started with .NET MAUI

Welcome to the world of .NET Multi-platform App UI (.NET MAUI)! This guide will walk you through the essential steps to set up your development environment and create your first .NET MAUI application.

What is .NET MAUI?

.NET MAUI is an open-source framework for creating native cross-platform applications for iOS, Android, macOS, and Windows from a single, shared C# codebase. It's the evolution of Xamarin.Forms, offering a more streamlined and powerful way to build modern apps.

Prerequisites

Before you begin, ensure you have the following installed:

Step 1: Install the .NET MAUI Workload

If you haven't already installed the .NET MAUI workload, you can do so using the .NET CLI. Open your terminal or command prompt and run:

dotnet workload install maui

Step 2: Create a New .NET MAUI Project

Once the workload is installed, you can create a new project. In Visual Studio, go to File > New > Project. Search for ".NET MAUI App" and select the template. Alternatively, use the .NET CLI:

dotnet new maui -n MyFirstMauiApp

This command creates a new MAUI project named "MyFirstMauiApp" in your current directory.

Step 3: Explore Your Project Structure

Open the created project in Visual Studio. You'll find a familiar structure:

Step 4: Run Your Application

Select your desired target platform (Android, iOS, Windows, or macOS) from the run dropdown in Visual Studio and click the run button. Your application will build and launch on the selected device or emulator.

Step 5: Modify the UI

Open MainPage.xaml. This file uses XAML to define the user interface. You can modify elements like buttons, labels, and layouts. For example, change the text of a label:

<Label Text="Hello, .NET MAUI World!" />

After making changes, save the file and rerun your application to see the updates.

Next Steps

Congratulations! You've created and run your first .NET MAUI app. Now, explore these resources to learn more: