MAUI The Future Of Xamarin.Forms

Let us remember that at the 2020 event (May 19-21), known as Microsoft Build, the company presented MAUI, the evolution of XAMARIN.

Similarly, let us remember that in 2016, at Xamarin Evolve it was announced that Microsoft was acquiring Xamarin. After multiple advances and updates in 2020, Microsoft announces MAUI within its "Journey to a single .NET" program on which the entire .NET 6 strategy is based. That is, a platform with the necessary tools to develop software for all platforms under the name of Multi-platform App UI (hence the acronym MAUI).

In Summary, MAUI will become one more Framework of .NET 6.

Note
MAC support is carried out with Mac Catalyst, which is a set of Apple APIs that allow iOS applications to run on MacOS.

Multi-platform App UI?

MAUI is the evolution of the well-known Xamarin.Forms, that is, a framework that allows us to create native interfaces for both mobile and desktop devices. The great novelty in MAUI is that if in Xamarin.Forms we need a solution for each platform within our project, we will now have a single code base in a single project.

MAUI will continue to use XAML for the UI adding support for MVU. As for patterns, we will continue to have MVVM and it will support the new MVU (Model-View-Update) which I will add Blazor support to.

With the MVU model, Microsoft also presents a unified way to build the cross-platform UI from a single Code base, that is, it allows us to write UI code and logic in C# as in the following example,

Let us consider what we know today as Xamarin.Essentials, is added to MAUI under the “System.Device” namespace and the specific namespaces for each platform disappear, encompassing everything in the new “Microsoft.Maui”.

In turn, they ensure from Microsoft that the parity of APIs will be 100%, everything available on one platform will be 100% available on the others. For example, today, in MacOS you do not have access to the Shell.

All this together with .NET 6 are the great news of MAUI that hit the market in November 2021 together with the release of .NET 6, with Visual Studio being the IDE for its development.

Simplified development

Thanks to what has already been said about simplifying the code to a single solution that contains the code for all platforms, the aim is to simplify the code, as well as the times.

Application resources such as images and sounds will be managed by the system and automatically adapted for each platform.

Specifically, we went from having a solution with shared code in the same project, on the other hand, the solutions of each platform (iOS, Android... etc) to having a single solution that supports everything mentioned above.

Migrating Xamarin.Forms to MAUI

For the migration of Xamarin.Forms applications to MAUI applications we will have a tool (today by command line, but it is not ruled out that it reaches the IDE). This tool will make the following changes:

  • Convert csproj project to SDK Style
  • Update target framework monikers
  • Change namespaces where necessary
  • CUSTOM RENDERERS* Microsoft.Maui.Compatibility

What this tool does not do,

  • Migrate to “Single project”
  • Fix deprecated APIs
  • Rewrite Custom Renderers to new “Handlers”

The most important change with MAUI is that the Renderers "disappear" giving way to the new Handlers.

This change what you are looking for,

  1. Facilitate accessibility
  2. Improved loading times and general performance of the app
  3. Direct access to native code from cross-platform code.

The migration tool will use Microsoft.Maui.Compatibility to make the old renderers compatible, but Microsoft highly recommends translating these renderers to the new Handlers.

Therefore, on this aspect, we have two differentiated options,

  • Use Handlers
  • Requires some time to perform code conversion
  • Each handler is equivalent to a Fast Renderer along with changes to Layouts to look for performance improvements.
  • Allows more extensibility options.
  • Use renderers:
  • No changes required

The Microsoft.Maui.Compatibility package is a NuGet package (it doesn't exist yet) with which we can make all those Xamarin.Forms "stuff" compatible until the migration to MAUI can be completed, such as,

  • Compatibility package
  • Renderers
  • Deprecated

As for third-party libraries, Microsoft assure that they are already working on migrations of these libraries to .NET 6 and optimizing for MAUI, they also have monthly meetings to help migrations.

More Information: https://docs.microsoft.com/en-us/dotnet/maui/


Similar Articles