Sharpening your .NET applications

In detail

Xamarin to MAUI Migration

Xamarin to MAUI Migration

What a challenge! According to Microsoft, it was supposed to be an extremely simple operation, essentially consisting of replacing namespaces in the declarations of XAML files. A migration that was not expected to cause any problems.

In practice, things were very different.

In 2020: migration to MAUI 6.0. The platform still lacked stability. The application remained plagued by NullReferenceExceptions. It would take until June 2023 and MAUI 7.0 before a version began to show encouraging signs of reliability. Another difficulty was the unavailability of some NuGet packages previously used with Xamarin. Fortunately, more proven stability arrived with versions 8.0 and later.

This migration was nevertheless a real opportunity.

MAUI is part of a truly cross-platform environment: Windows, Android, iOS and Linux. Rather than migrating each Xamarin application individually, it became possible to rethink the overall architecture. A substantial part of the code could now be shared across a whole range of applications, services, … whether front-end, back-end or mobile applications. This made it possible to rethink the code architecture around a genuine API, genuine business engines, … shared by a much broader set of projects, extending far beyond the scope of a single Xamarin application. Compiling class libraries with conditional compilation directives such as #if IOS or #if ANDROID became a powerful way of standardising code across very different applications.

Removing obsolete components

In Xamarin, StackLayout was our friend. In MAUI, it no longer is. The FillAndExpand values should be avoided. Grid has become the component of choice. ListView is also giving way to CollectionView. And Frame is being replaced by Border. These are all deprecations that need to be addressed progressively in order to remain aligned with the evolution of the platform.

Dynamic XAML was affected too.

One application I had to migrate allowed users to define XAML code in a « desktop » application, which was then dynamically injected into the mobile application. Of course, a whole series of XAML keywords had either disappeared or changed. Default sizes changed on Android (Font="Large" became FontSize="Medium"), grids now have to explicitly define all columns and rows, some StackLayouts are good candidates for conversion to VerticalStackLayouts or HorizontalStackLayouts, … All of these changes were handled transparently by dedicated code in order to maintain as much backward compatibility as possible with existing configurations.

Ultimately, this migration, initially perceived as a difficulty, turned out to be a genuine opportunity. It made it possible to rethink the overall architecture, share more code and reposition the applications on a modern, more open and more sustainable platform.

Previous Next
All products, technologies, and company names mentioned on this website are trademarks or registered trademarks of their respective owners. The Microsoft products cited (SQL Server, Windows, MAUI, Xamarin, .NET, Blazor,...) are trademarks of Microsoft Corporation. Ubuntu is a registered trademark of Canonical Ltd.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.