A first look at .NET MAUI

Microsoft recently released its new, highly anticipated cross-platform application building tool .NET MAUI. Does the new tool have what it takes to be a proper successor to Xamarin? And what benefits and new features does it bring to the table for cross-platform developers? Our colleague Piotr Pietrzak had a first look to find out if the wait has been worth it.

What is .NET MAUI?

.NET MAUI (Multi-platform App UI) is the highly anticipated open-source cross-platform application building tool to succeed Xamarin, which in .NET MAUI was extended with desktop scenarios. .NET MAUI provides a single project that handles all the multi-targeting across devices and their platforms. In .NET MAUI you can develop applications for the following platforms:

  • Windows 11 and Windows 10 version 1809 or higher, using Windows UI Library (WinUI) 3,
  • macOS 10.13 or higher, using Mac Catalyst,
  • iOS 10 or higher,
  • Android 5.0 (API 21) or higher

and additionally:

  • Tizen, supported by Samsung,
  • Linux, supported by the community.

Android and iOS applications with an interface built by MAUI technology can be created in Visual Studio for Windows and Mac in the Visual Studio 2022 in 17.3 version (on Mac it needs also Xcode 13.0 or higher), while creating applications for Windows and macOS is possible just in Visual Studio for the right system.
.NET MAUI is a part of .NET Core (currently renamed as a .NET 6) and it has been released on 9th of August for Windows. Microsoft’s developers are still working to release many of these amazing tools for Mac developers as well, but now it is still only available in preview version for them.

Who is .NET MAUI for?

If you are a developer who wants to:

  • develop cross-platform apps in XAML and C#, with a single shared codebase in Visual Studio
  • share UI and design across platforms,
  • share code, business logic, and tests across platforms

.NET MAUI is for you!

How does .NET MAUI work?

Basically, .NET MAUI is all about the unification of the above mentioned platforms’ APIs into a single API.

As was already mentioned, .NET MAUI is part of .NET 6, which provides platform-specific frameworks for creating apps: .NET for Android, .NET for iOS, .NET for macOS, and Windows UI 3 (WinUI 3) library. The library which connects all of them is .NET 6 Base Class Library (BCL) based on Win32 with UWP in Windows and Mono Runtime in rest systems. This library abstracts the details of the underlying platform away from your code and allows for sharing common business logic between them. But all platforms have different approaches to defining the UI of an application. So the developer can create the UI for each of them separately using the platform-specific framework.

.NET MAUI provides a single framework for building the UIs for mobile and desktop apps.

It unifies systems which allow to create applications with graphical user interfaces for the above mentioned platforms in XAML. But it is not a one and only possibility. The new thing is that you can use Blazor as well (which is associated mostly with Web applications) for this.

Apart of graphical aspects of applications, .NET MAUI also unifies some other parts of applications like access to sensors, e.g. gyroscope or accelerometer, file access and data storage mechanisms, network state tracking or access to device information.

Thanks to that, native client apps can be build with a single codebase (with some platform-specific files just in case, without separating that in different projects). This can be really helpful and means that, to some extent, an application can be written without taking care of differences in code for other platforms. Such an approach is known as ‘write-once, run-anywhere’ (WORA) which has been known in software developing for a long time.

The conclusion is that you write code which is able to interact with .NET MAUI API, and then it directly consumes the native platform APIs. In addition, app code may directly exercise platform APIs, if required. Quite simple, isn’t it?

Image source: https://docs.microsoft.com/en-us/dotnet/maui/

 What does .NET MAUI offer to developers?

✅ Single development stack that supports all modern workloads with a unified SDK, base class libraries and toolchain,

✅ Multi-platform APIs for native device features include access to over 60 platform features, including isolated storage, sensors, geolocation, camera,

✅ Rich collection of pages, layouts, and controls (build from C# or XAML),

✅ Support for two-way data binding to easily have a code update when users interact with a UI,

✅ URI-based navigation system which uses routes to navigate to any page in the app without having to follow a set navigating hierarchy (with navigate backward without visiting all pages on the stack),

✅ Support for Hot Reload (C# and XAML) and XAML Live Preview technologies to make developers much more productive building .NET MAUI apps,

✅ Latest debugging features, IntelliSense, and testing features of Visual Studio to write better code faster,

✅ Support for modern patterns: MVU (model-view-update) and Blazer development patterns,

✅ Hybrid Development with Blazor,

✅ Visual State Manager which manages states and the logic for transitioning between states for controls,

✅ Animation API,

✅ Dependency Service,

✅ Messaging Center to Pub/Sub,

✅ CI/CD Support

and much more!

How does the .NET Maui project architecture look like?

1. One single project that hosts all of the source code for the project including UI, platform code, shared resources, app manifest, and more.
2. Cross-platform resources (fonts, images, and raw assets are all contained in the project).
    a. Fonts – automatically configured per platform.
    b. Images – resized and SVG converted.
    c. App Icons and Splash screens supported.
3. Platform-specific folders hold platform-specific resources, configuration, startup logic and platform code.


.NET MAUI is a quite new product so it is still too early to judge how big of an impact it will have on the field of cross platform app development tools. Microsoft strongly hopes that it will effectively success Xamarin which popularity has been decreasing for some time now. 

What is attractive about this product is the unification of the tools used to create cross-platform applications. This looks really good from a UI perspective as well as from a business perspective.

Hopefully, Microsoft will be still working to improve product and they will support this for a long time.

Piotr Pietrzak
Software Commissioning Engineer

Source: https://docs.microsoft.com/en-us/dotnet/maui/