What if we could create native mobile apps and desktop apps using .NET C# and XAML from a single code base? How cool would that be? Yes, now we can create native Android, iOS, macOS, and Windows applications from a single code base. This is possible using .NET’s new feature called Multi-platform App UI (MAUI). .NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating native mobile and desktop apps with C# and XAML. Microsoft Build 2020 announced that Microsoft has evolved Xamarin.Forms and taken the next step in the .NET unification to give us a cross-platform mobile-first framework for Android, iOS, macOS, and Windows. .NET MAUI will introduce new ways to build applications – available in .NET 6 and in preview now!

What is .NET MAUI?

.NET Multi-platform App UI (MAUI) is the evolution of Xamarin. Forms extended from mobile to desktop scenarios with UI controls rebuilt from the ground up for performance and extensibility. – Maddy Leger, Program Manager Xamarin/.NET MAUI Team. is an open-source cross-platform framework which can be used to develop and build native Android, iOS, macOS, and Windows applications from a single code base.

What are Xamarin and Xamarin.Forms?

Xamarin is an open-source .NET platform for building iOS, Andriod, macOS, and Windows applications. It was introduced in 2011. It allows us to share business logic across platforms, using .NET, while creating a native UI for each. Xamarin allows developers to share an average of 90% of their application across platforms. To help with the overhead of creating native UI’s for each platform, we have Xamarin.Forms.

Xamarin.Forms is an open-source UI framework that allows us to combine the code for Xamarin.Android, Xamarin.iOS, Xamarin.Mac, and Windows applications into a single shared codebase.

Microsoft is now thinking about creating a unified .NET platform that can replace .NET Framework, .NET Core, and Xamarin. .NET MAUI is the next step in unifying .NET by replacing Xamarin.Forms. It addresses some of the issues and downsides of Xamarin.Forms, while providing an updated architecture on top of the new generation of .NET and project system.

Difference between MAUI and Xamarin.Forms

Microsoft is rebuilding the core of Xamarin.Forms, bringing us performance improvements, consistent design systems, and an extension from mobile to desktop. Now you may ask if we use Xamarin.Forms then why should we move to MAUI? Why is so special about MAUI?

.NET MAUI provides cross-platform APIs for native device features. It has some major Improvements like a Single project experience across platforms and .NET hot reload. It MAUI allows us to have a single project experience instead of one project for each target platform. We can use one language across our application to target all the supported platforms and easily share resources across them while maintaining an option for platform-specific code. Also the Model-View-ViewModel (MVVM) and XAML pattern used in existing Xamarin.Forms applications will continue to be supported and improved with the evolution. .NET MAUI will introduce further support for the Model-View-Update (MVU) development pattern, popular in C#, enabling developers to write fluent C# UI and create a code-first development experience.

How .NET MAUI works?

.NET MAUI unifies Android, iOS, macOS, and Windows APIs into a single API that allows a write-once run-anywhere developer experience, while additionally providing deep access to every aspect of each native platform.

.NET 6 provides a series of platform-specific frameworks for creating apps: .NET for Android, .NET for iOS, .NET for macOS, and Windows UI 3 (WinUI 3) library. These frameworks all have access to the same .NET 6 Base Class Library (BCL). This library abstracts the details of the underlying platform away from your code. The BCL depends on the .NET runtime to provide the execution environment for your code. For Android, iOS, and macOS, the environment is implemented by Mono, an implementation of the .NET runtime. On Windows, Win32 provides the execution environment.

.NET MAUI provides a single framework for building the UIs for mobile and desktop apps. The following diagram shows a high-level view of the architecture of a .NET MAUI app:

.NET MAUI architecture diagram.

In a .NET MAUI app, you write code that primarily interacts with the .NET MAUI API (1). .NET MAUI then directly consumes the native platform APIs (3). In addition, app code may directly exercise platform APIs (2), if required.

About .NET hot reload

.NET MAUI includes support for .NET hot reload, which enables you to modify your managed source code while the app is running, without the need to manually pause or hit a breakpoint. Hot reload increases productivity for .NET developers, allowing instant updates to running applications with new code changes. .NET MAUI includes support for XAML hot reload, which enables you to save your XAML files and see the changes reflected in your running app without recompilation. In addition, your navigation state and data will be maintained, enabling you to quickly iterate on your UI without losing your place in the app.

During Microsoft Build 2021, Microsoft announced the availability of .NET MAUI Preview 4. Each preview provides us with more features and tools with general availability scheduled for November 2021 at .NET Conf. With the release of Preview 4, we can now create functional applications across all supported platforms using .NET MAUI. In addition, they have added new capabilities to support running Blazor on desktop using .NET MAUI, allowing the reuse of Blazor UI components across native desktop and web applications. Alongside Preview 4 is the release of Visual Studio 2019 version 16.11 Preview. The Visual Studio 2019 16.11 Preview enables .NET Hot Reload for MAUI and provides productivity features for developing .NET MAUI projects. To see what is coming in future releases, visit the MAUI product roadmap.

Share and Enjoy:
  • Digg
  • Twitter
  • Facebook
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Google Bookmarks
  • Slashdot