What is .NET MAUI?

Why Migration Needed

Set Priority During Migration

  1. Priority 1 - Give priority to just convert your Xamarin Form project into .NET MAUI; it should build and run on the device irrespective of UI & other inner functionality.
  2. Priority 2 - Once your application is running using MAUI, then you can focus on UI and inner functionality to be functional

Migration Way

  1. Upgrade Assistant - Upgrade Assistant for .NET MAUI is still under development as of Oct. 2023
  2. Manual Upgradation - We can migrate by adding the Xamarin Form codebase into the MAUI project and doing the necessary changes to remove Xamarin Form dependency.

Migration from Xamarin Forms to MAUI using Manual Upgradation

  1. Create a new blank MAUI project.
  2. Xamarin Independent Libraries- Add these libraries references directly in the MAUI project (Make sure these libraries support the MAUI project, if not, then firstly, you have to make this library compatible with the MAUI project, and then you can add them as references)
  3. Xamarin Dependent Libraries- Initially, you can add the codebase of these libraries directly in the MAUI project and make the changes to remove Xamarin Dependency.
  4. Remove Xamarin dependency if you copy the Xamarin Forms code into the MAUI project-
    1. Copy all your Xamarin code into the MAUI project - .xaml, .cs, Assets, Fonts, Themes, and Images.
    2. Font integration - Change the build action of the font file to MauiFont and add a reference in MauiProgram.cs
    3. Change the build action of your all .xaml file from embedded resources to mauixaml, as mauixaml is the default build action for MAUI xaml pages.
    4. Replace all: xmlns="http://xamarin.com/schemas/2014/forms" to xmlns="http://schemas.microsoft.com/dotnet/2021/maui" as new namespace is the default namespace for MAUI xaml pages.
    5. Remove or change unnecessary references from .xaml & .cs pages: Xamarin & Other references, if any.
    6. Change Color.Default to new Color()
    7. Change Xamarin.Forms.Color to Microsoft.Maui.Graphics.Colors
    8. Make the placeholder changes for Renderers, Dependency Service, and custom code if any (Optional)
    9. Rebuild & Run

Note

Migration Video

https://youtu.be/_E1DcFRDFiU?si=QKl53PthkiNSxO2K