.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.
.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.
Before you begin, ensure you have the following installed:
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
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.
Open the created project in Visual Studio. You'll find a familiar structure:
Platforms
: Contains platform-specific code.Resources
: Holds assets like images, fonts, and styles.App.xaml
and App.xaml.cs
: The entry point of your application.AppShell.xaml
and AppShell.xaml.cs
: Defines the overall navigation structure of your app.MainPage.xaml
and MainPage.xaml.cs
: The starting UI page.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.
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.
Congratulations! You've created and run your first .NET MAUI app. Now, explore these resources to learn more: