What is .NET MAUI: How it works, How it is different from Xamarin. forms?

By Rania Nov 28, 2022, 7:39:48 AM , In Automation
What is .NET MAUI: How it works, How it is different from Xamarin. forms?

Table of Contents

Welcome to .NET MAUI world!

The popularity of Microsoft .NET Core tools is being driven by the need for smaller, more nimble developer tooling that can keep pace with the rapid release cycles of modern applications. Microsoft has finally evolved Xamarin forms and provided us with the .Net unification for a better, faster, and smarter cross-platform development experience. As announced by the tech giant Microsoft, The .NET Multi-platform App UI will root change how you develop apps in the long run.

This article is about all you need to know about .NET MAUI the new generation of Xamarin.

What is .Net MAUI?

The .NET Multi-platform App UI is an open source framework for building modern, multi-platform, natively compiled iOS, Android, macOS, Windows and apps using C# and XAML in a single codebase with UI controls rebuilt from the ground up for higher performance and extensibility.

MAUI will feel familiar to Xamarin users, but instead of generating codes separately for different platforms, it generalizes all of your code in a single project. The goal behind.NET MAUI is to enable its users to implement as much app development logic and UI layout as possible in a single code base.

Why developers should opt for .net MAUI?

MAUI is meant to help developers deliver high-performance, cross-platform, native desktop and mobile apps from a single codebase. This means the capacity to build apps for any device from a single codebase and project system, using one language, one set of libraries, and one UI stack for all.

.NET MAUI is for developers who are looking to:

Infographic of why developers should opt for dot net MAUI

  • Develop cross-platform apps in XAML and C#, from a single shared code base in Visual Studio.
  • Create a sharable UI layout and design across multiple platforms.
  • Share code, tests, and business logic across platforms.
  • Adapt to the constant changes in app requirements by building apps that can be easily modified or extended over time.

The decoupled UI and single project enable developers to stay focused on one application instead of juggling the unique needs of multiple platforms.

How .NET MAUI works?

.NET MAUI combines the Android, iOS, macOS, and Windows APIs into a unified API that enables developers to create code once and run it anywhere while providing access to each native platform feature.

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

A high-level view of the architecture of a.NET MAUI app is presented In a .NET MAUI app, the written code 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.

.NET MAUI apps can be written on PC or Mac, and compiled into native app packages:

  • When creating an Android app with.NET MAUI, C# is first translated into an intermediate language (IL), which is then JIT-compiled into a native assembly when the program is launched.
  • Native ARM assembly code is entirely ahead-of-time (AOT) and compiled from C# for iOS apps created with .NET MAUI.
  • Mac Catalyst, an Apple product, is used by macOS programs produced with .NET MAUI to bring your iOS app built with UIKit to the desktop and enhance it as necessary using additional AppKit and platform APIs.
  • Windows apps developed with.NET MAUI take advantage of the Windows UI 3 (WinUI 3) library to produce native Windows desktop applications. See the Windows UI Library for more details on WinUI 3.

How MAUI is different from Xamarin. Forms?

If you are a Xamarin. Forms user, then .Net MAUI will definitely feel familiar, but what edge benefits it brings to the table?

.Net MAUI comes with specific performance improvements, consistent design systems, and an extension from mobile to desktop, as well as a Single project experience across platforms with modern app patterns.

Here are some major key benefits that differentiate MAUI

1) Single project experience

Instead of working on separate projects for each target platform, developers can leverage .NET MAUI to target and debug several devices without moving between projects or managing the quirks of each platform, a single project enhances the developer experience. While keeping the possibility for platform-specific code, we may utilize a single language across the application to target all the supported platforms and easily share resources between them.

2) .NET Hot Reload

Because hot reload enables immediate updates to running applications with fresh code changes, it boosts productivity for.NET developers. It saves time and permits the development flow to continue by eliminating the build and deploy interruptions. Hot Reload is being expanded in.NET, giving full support for.NET MAUI and other workloads.

3) Modern app patterns

Existing Xamarin uses the Model-View-ViewModel (MVVM) and XAML patterns. Applications will continue to be maintained and enhanced as technology advances. Further support for the Model-View-Update (MVU) development paradigm will be added by .NET MAUI, allowing programmers to construct fluent C# UI and experience code-first development.

4) Highly adaptable architecture

When it comes to designing, requirements changes can be a challenging burden since such adaptability necessitates an architecture that enables individual components of the app to be independently developed and tested in isolation without affecting the rest of the program.

5) Compatibility

NET MAUI apps can be written on PC or Mac, and compiled into native app packages. While iOS’s apps built using .NET MAUI are fully ahead-of-time (AOT) compiled from C# into native ARM assembly code. macOS’s apps built using .NET MAUI use Mac Catalyst, a solution from Apple that brings your iOS app built with UIKit to the desktop, and augments it with additional App Kit and platform APIs as required, Windows apps built using .NET MAUI use Windows UI 3 (WinUI 3) library to create native apps that target the Windows desktop. For more information about WinUI 3, see Windows UI Library.

6) Single asset management

Resources like fonts, graphics, splash screens, CSS, and raw materials can all be managed in one location. the location of Xamarin. There are numerous projects for forms.

7) Using multiple targets to group platform-specific code

Each child folder in the Platforms folder of a.NET MAUI project represents a different supported platform. Consequently, managing platform-specific code is simple.

8) Assistance with the Model View Update (MVU) design pattern

The Model-View-View model and Reactive UI patterns are supported by Xamarin. Forms. Additionally, the Model-View-Update and Blazor development patterns are supported by.NET MAUI. With the help of this technique, you may create native, cross-platform front ends from a single code base.

9) Assistance for Blazor

Blazor is one of the most adaptable programming paradigms for creating web applications, as is well known. Blazor’s target scenarios will be expanded by.NET 6 to enable native desktop apps that might rely on web-based rendering. The Blazor desktop will be organized similarly to how the Electron is set up.

10) Cross-platform APIs for device features

.NET MAUI provides cross-platform APIs for native device feature for accessing device the features includes access to sensors, such as the accelerometer, compass, and gyroscope on devices, network connectivity state, Copy and paste text to the system clipboard, between apps, Pick multiple files from the device, store data securely as key/value pairs, utilize built-in text-to-speech engines to read text from the device .etc

Leverage the power of .Net MAUI for your upcoming app

With its collection of controls that can be used to display data, initiate actions, indicate activity, display collections, pick data, and more. In addition to a collection of controls, .NET MAU also

  • Elaborates layout engine for designing pages.
  • Supports data-binding, for more elegant and maintainable development patterns.
  • Cross-platform APIs for accessing native device features.
  • Cross-platform graphics functionality

Dot NET Multi-Platform App UI: FAQ

How to Migrate your app from Xamarin.Forms?

You don't need to rewrite your Xamarin. Forms apps to move them to .NET Multi-platform App UI (.NET MAUI), however small changes in code are required

Does .NET MAUI Web work?

.NET MAUI is the latest tool to promise one code base for cross-platform deployment on desktop and mobile.NET MAUI does not support the web, but developers can utilize the Blazor framework to provide a bridge to use MAUI resources

Does .NET MAUI support XAML and MVVM?

Absolutely! You can use XAML with markup extensions, data binding, compiled bindings, visual state manager, styles, data templates, native views, and more.