Microsoft Learn

MAUI Architecture

.NET Multi-platform App UI (MAUI) is a cross-platform framework for creating native mobile and desktop apps with C# and XAML. It builds on the foundations of Xamarin.Forms, enabling you to develop applications that can run on Android, iOS, macOS, and Windows from a single, shared codebase.

Core Concepts

MAUI's architecture is designed to provide a clean separation of concerns and maximize code reuse across platforms. Key concepts include:

High-Level Architecture Diagram

MAUI Architecture Diagram

Conceptual diagram of MAUI's layered architecture.

Key Components

The MAUI architecture can be understood as a series of layers:

1. .NET MAUI API Layer

This is the primary API that developers interact with. It provides a rich set of controls, layouts, and APIs for building your application UI and logic. This layer is platform-agnostic and designed for maximum code sharing.

2. .NET MAUI Essentials

MAUI Essentials is a .NET library that provides cross-platform APIs for accessing device features such as sensors, storage, and network information. It simplifies common tasks that would otherwise require platform-specific code.

3. Platform Abstraction Layer (PAL)

This layer contains the platform-specific implementations of the MAUI API. For each target platform, there's a corresponding implementation that maps the MAUI API calls to the native platform APIs.

4. Native UI Toolkits

At the bottom of the stack are the native UI toolkits and operating system APIs for each platform. MAUI leverages these to render the UI and provide native behavior.

Development Workflow

With MAUI, your development workflow typically involves:

  1. Writing C# and XAML code in a single project.
  2. Using MAUI controls and layouts to define your UI.
  3. Leveraging MAUI Essentials for device features.
  4. The MAUI framework handles the translation of your shared code into native UI elements and behavior for each target platform.
  5. Deploying your application to Android, iOS, macOS, or Windows.

Benefits of MAUI Architecture

Note: Understanding the MAUI architecture helps in writing efficient, maintainable, and performant cross-platform applications.