At the beginning of January 2021, Microsoft released the latest version of Xamarin.Forms 5.0 and announced that it was the final update bringing new features. With this, Microsoft developers focused on the MAUI framework. In this blog post, I will introduce you to what .NET MAUI is and what possibilities it offers.
So it is a cross-platform framework for developing native mobile and desktop applications using C# and XAML. .NET MAUI allows you to create apps that launch on Android, iOS, macOS and Windows from a single shared code base.
Bye, bye Xamarin
As I mentioned, .NET MUAI is the next step after Xamarin – extended from mobile to desktop scenarios, with UI controls rebuilt from scratch for performance and extensibility. One of the main goals of the .NET MAUI platform is to enable as much of the application logic and user interface layout as possible to be implemented in a single code base.
How it exactly works?
This platform consolidates Android, iOS, macOS and Windows APIs into a single API that enables developers to run their app anywhere using the same code while providing profound access to every aspect of each native platform.
Architecture of a .NET MAUI application
Graphical presentation of some technical stuff often helps with better understanding, so let me present the architecture of a typical .NET MAUI app.
So as you can see, in a .NET MAUI app, you implement code that firstly interacts with .NET MAUI API. Then, .NET MAUI directly consumes the native platform APIs. Additionally, application code may directly exercise platform APIs. These frameworks (.NET for iOS, .NET for Mac, .NET for Android and Windows UI 3) have access to the same .NET 6 Base Class Library (BCL).
.NET 6 BCL
This library extracts the details of the underlying platform from the code. BCL depends on the .NET platform runtime environment to provide the code execution environment. For iOS, macOS and Android, the environment is provided by Mono, an implementation of the .NET runtime environment. On Windows, Win32 supplies the execution environment.
Let’s try creating something 😉
First of all, you need to download and install Visual Studio 2022 Preview. At the installation process, the .NET Multi-platform App UI workload shall be selected.
Thereafter, open Visual Studio 2022 Preview and create a new project by selecting the .NET MAUI App template.
If you would like to deploy that application to your local Windows machine, then you need to enable developer mode. Go to the Settings and switch on the toggle below Developer mode:
Finally, you are ready to run and deploy your app to Windows. So choose Start Debugging from the main menu and after some seconds, you will see something like that:
Your first .NET MAUI app has become a fact! 🙂
I wanted to make a quick intruduction about .NET MAUI, cause it is really promising framework. I am curious how it evolves and if it will be a good alternative for creating native apps. I would like to dive more deeply in .NET MAUI, so probably more content about that will appear soon. Stay tuned! 🙂