.NET MAUI Application Types
.NET 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. It's the evolution of Xamarin.Forms, allowing you to build applications for Android, iOS, macOS, and Windows from a single project.
What is .NET MAUI?
.NET MAUI provides a unified platform to build native applications that can run on multiple operating systems. It offers:
- Single Project: Manage all your platform-specific assets and code in a single project file.
- Cross-Platform UI: Define your UI once using XAML or C# and render it natively on each platform.
- Native Performance: Applications are compiled to native code, offering excellent performance.
- Rich Ecosystem: Leverage the power of the .NET platform, including C# and all its libraries.
- Modern Development: Built on .NET 6 and later, it embraces modern .NET development patterns.
Key Features
Cross-Platform UI Controls
.NET MAUI includes a comprehensive set of built-in UI controls that render natively on each target platform. These controls are designed to be flexible and customizable.
Example of a button:
<Button Text="Click Me"
HorizontalOptions="Center"
VerticalOptions="Center" />
XAML for UI Definition
XAML (eXtensible Application Markup Language) is a declarative language that allows you to design your application's user interface separately from its business logic. This separation improves maintainability and collaboration.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyMauiApp.Views.HomePage"
Title="Home">
<StackLayout>
<Label Text="Welcome to .NET MAUI!"
FontSize="32"
HorizontalOptions="Center" />
<Button Text="Go to Settings"
Clicked="OnSettingsClicked"
HorizontalOptions="Center" />
</StackLayout>
</ContentPage>
C# for Logic and Behavior
Your application's logic, event handling, and data manipulation are written in C#. .NET MAUI seamlessly integrates C# code-behind with XAML views.
public partial class HomePage : ContentPage
{
public HomePage()
{
InitializeComponent();
}
private void OnSettingsClicked(object sender, EventArgs e)
{
// Navigation logic here
Navigation.PushAsync(new SettingsPage());
}
}
Platform-Specific Development
While .NET MAUI aims for maximum code sharing, you can still access platform-specific APIs and features when needed. This allows you to tailor your application to the unique capabilities of each operating system.
Supported Platforms
- Android
- iOS
- macOS (via Mac Catalyst)
- Windows (via WinUI 3)
Next Steps
Ready to start building? Explore the following sections: