You might have thought that it could be so beneficial if creating native mobile and desktop apps with the use of .NET C# & XAML from one code base was possible!
It is possible!
Now, .NET developers can develop native iOS, Android, Windows, and macOS apps from a single code base. It is possible with the MAUI feature of .NET. MAUI stands for Multi-platform App UI. To get some core idea about what .NET MAUI is, you can stay tuned with us till the end of this article.
A seasoned .NET development company would always prefer to provide .NET MAUI services to its clients. Using this feature, you can develop apps that are easily executable on macOS, iOS, Windows, etc., without the need to write different codes for different platforms.
.NET MAUI can be thought of as an advanced version of Xamarin.Forms as it has some modern features like UI controls that are optimized and redesigned for improved scalability and performance.
It’s also equipped with the feature of XAML hot reload, which helps in updating your app UI when you update your XAML code without the need to recompile. In the same way, it also supports .NET hot reload.
Now, let’s explore more about .NET MAUI, its performance, architecture, and much more. So, let’s dive in!
.NET MAUI- Basic Overview
.NET MAUI is a framework for developing the latest multi-platform, Android, compiled iOS, Windows, and also apps using XAML and C# in one codebase.
With this feature of .NET, you can develop native apps from one codebase for different platforms.
In case you have worked with Xamarin forms, MAUI becomes familiar to you. Rather than different projects for mobile, desktop, and other OS, all the code remains in one single project.
It also provides easy hosting of Blazer in MAUI, along with embedded web controls. These controls help in executing Razor components natively on the target device.
The decoupled UI and one project help you to remain focused on the app rather than juggling the unique needs of each platform. It’s just the beginning of .NET MAUI, and there are high chances of many useful libraries and a huge ecosystem to be integrated into this system in the upcoming time.
Who can use .NET MAUI?
.NET MAUI is generally used by the companies using .Net to develop application who are looking forward to:
Sharing UI layout and other designs across different platforms.
Writing code for cross-platform apps in C# and XAML using a single-shared code base in the Visual Studio environment.
Sharing of code, business logic, and test cases across different platforms.
These are some of the primary usages of .NET MAUI. Now, let’s see how this feature works.
How does .NET MAUI work?
.NET MAUI combines with iOS, macOS, Android, and Windows in a single API that provides WORA - Write Once Run Anywhere functionality. It provides in-depth access to each aspect of every native platform.
.NET 6 or later versions provide different platform-specific frameworks for developing apps such as .NET iOS, .NET Android, Windows UI 3 Lib (WinUI 3), .NET macOS, and much more. These frameworks have access to the same .NET BCL (Base Class Library). This library summarizes the information of the platform away from the code.
The BCL will depend on .NET runtime for providing the execution env for the code. For iOS and Android, the environment is used by Mono, and a .NET runtime implementation remains helpful. Moreover, on the Windows network, .NET CoreCLR gives the execution environment.
While the BCL helps the apps running on various common business logic, the different platforms get different ways of defining the UI for an app and also provide different models for personalizing how the elements of a UI interoperate and communicate.
You can easily craft the UI for each separately with the use of an accurate platform-specific framework like .NET iOS, .NET Android, .NET macOS, or WinUI3, but in this approach, you will have to maintain a particular code-base for each and every device.
What makes .NET MAUI different?
If you are aware of what Xamarin.Forms are, you might be thinking why use .NET MAUI? Microsoft is redeveloping the primary Xamarin.Forms, and brings us consistent design, improvements, and extension from the phone to the desktop.
Key features and functions of MAUI:
.NET hot reload support
Experience single project across different platforms
Latest App Patterns
Let’s understand each of these points in detail.
Support for .NET Hot Reload
.NET Hot Reload improves the productivity of the .NET development services providers. It also allows quick updates to run apps with the latest code changes. It removes the deployment and build interruptions saves time and allows the continuous development flow. The .NET team is trying to expand the Hot Reload that brings full support to the .NET MAUI with various workloads.
Single Project Experience
.NET MAUI helps the users to have a single project experience rather than one project made for each platform.
In a single project, the developer experience is improved by helping the developers to debug and target various divides without shifting from one project and navigating the tricks of every platform.
You can also use a single language across the app to target different platforms that are supported. This also helps in sharing the resources across them and maintaining an alternative for the code that is platform-specific.
Modern Application pattern
With the MVVM, that is Model-View-ViewModel and XAML pattern of Xamarin.Forms, the apps will get continuous support and will be evolved with time.
.NET MAUI introduces advanced support for the MVU, i.e., the Model-View-Update pattern of development that is well-known in the C# language. It enables developers to write fluent C# UI and make a code-first experience.
Now let’s understand what we get from the .NET MAUI.
What does .NET MAUI provide?
.NET MAUI has a varied collection of controls that are used to show data, indicate activity, initiate actions, pick data, display collections, and much more. Additionally, this collection also provides:
Different page types for making rich navigation such as drawers
Elaborated layout engine that helps in designing different pages
Supports data-binding for elegant and maintainable development patterns.
Cross-platform APIs that help in accessing native features. APIs also help the applications to access device features like accelerometer, GPS, network and battery states, etc.
MAUI also provides the ability to customize handlers that enhance the way of the presentation of various UI elements.