What is .NET MAUI?

20 december 2021 om 10:00 by ParTech Media - Post a comment

With the latest .NET 5 release, Microsoft has united .NET Core and Xamarin under one base class and single SDK(software development kit). If you are a .NET developer, then the chances are high that you would have heard about the new .NET MAUI(Multi-platform App UI) released by Microsoft. More importantly, it is an evolution of the Xamarin. Let’s understand more about this starting from the history of Xamarin.

Table of Contents

  1. History of Xamarin
  2. How is .NET MAUI different from Xamarin.Forms?
  3. Features of .NET MAUI
  4. Final Thoughts

History of Xamarin

Xamarin is an open-source development platform that extends the capability of .NET development platform using tools and libraries for developing iOS, Android, and desktop apps. Back in 2016, when Microsoft acquired Xamarin, their main goal was to unify all cross-platform development tasks under a single code base.

They wanted timplement C# as the language of choice to build apps once and run them anywhere. They needed to bring Xamarin into the .NET platform completely. And that's how .NET MAUI came into the picture.

But even today, a lot of people confuse .NET MAUI with Xamarin.Forms. Let's clear the clutter for you.

How is .NET MAUI different from Xamarin.Forms?

Xamarin .Forms is a cross-platform application development platform that is used for building mobile apps(both Android and iOS) under a single shared codebase. On the other hand, .NET MAUI brings desktop apps under the umbrella of cross-platform application development. That is why .NET MAUI can be considered an extension of Xamarin.Forms feature. If you have previously worked on Xamarin.Forms for building cross-platform UI interfaces, then you will see its similarities with the .NET MAUI.

.NET MAUI is more or less a rewrite of Xamarin.Forms except for the fact that it is included in the .NET BCL(Base class library). This means it is not a separate entity as it was before.

The .NET base class library encapsulates common functions and allows developers to access all these data resources under a single common umbrella. It serves as the point of interaction between the developer and the runtime environment.

As .NET MAUI is still in the preview version, Microsoft suggests starting new projects with .NET MAUI as it is released for GA(General availability). Microsoft is also pressing on making the transition from Xamarin to .NET MAUI as seamless as possible.

If you are working on small projects, you can switch to MAUI with minimal effort. But if it is a large enterprise project, it is advisable to wait until Microsoft releases tooling support to make the transition simpler for you.

Also, apart from applying the same design code across multiple platforms, MAUI also allows applying the same business logic, testing code and APIs.

Features of .NET MAUI

Maui offers a collection of controls used to display data, initiate actions, measure activity, and form controls. Apart from these controls, MAUI provides a plethora of resources. Here are they -

  1. Provides a large user interface layout engine for designing pages.
  2. Provides viable information about the device on which your application is running.
  3. Provides rich navigation and intuitive UI elements for multiple page types, like drawers and skeletons.
  4. Provides options to customize event handlers to enhance the way UI works, which is not provided by many development platforms.
  5. Supports robust data binding, leading to reliable and optimized development patterns.
  6. Supports cross-platform APIs for developing native applications. These APIs can help you access the device’s kernel, sensors, accelerometers, GPS, network state, and even the battery.
  7. Provides a cross-platform graphics library, that provides a common API targeting multiple platforms, so that you can share your 2D drawing code across multiple platforms or use a predefined graphics gallery within a single app.
  8. Another remarkable feature provided by MAUI is that it supports hot reload. Hot reload is a feature that allows you to edit/change your application code, even when your app is running. This means that you need not wait to pause or hit a breakpoint. And your code edits will be simultaneously applied to your codebase when your app is running without recompilation. MAUI supports XAML hot reload, which means you can edit your XAML files on the run and see the changes reflected in your codebase rather than recompiling it.
  9. A single project setup to target multiple platforms(Android, iOS, Mac, or Windows).

So you need not create different project setups and reincorporate the same code every time in the new environment.

Final Thoughts

Microsoft has postponed the release for the General availability of .NET MAUI to the early Q2 of 2022. However, it has made sure that developers will get monthly previews of .NET MAUI, while Xamarin remains the official product for building mobile applications and other products.

The latest MAUI preview was released in September 2021 - Preview 8. Preview 8 holds many features including the update for the app startup pattern, the ability to extend a handler, and other new control features.

Also, .NET MAUI will be accessible as an available workload in the latest Visual studio 2022. While installing the Visual Studio 2022, developers can choose .NET MAUI(preview) within the mobile development of the .NET workload. Also, updates in the Visual Studio bring improvements in XAML hot reload and .NET hot restart. This is an advanced mechanism for restarting applications seamlessly when an error or serious failure occurs.