.NET MAUI quality improvements in Preview 12

Reading time icon 2 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more

Microsoft just released Preview 12 of the .NET Multi-platform App UI otherwise known as .NET MAUI. For those living under a rock, this is a cross-platform framework for creating native mobile and desktop applications levering .NET and C#. This allows developers to build applications that work across pretty much any operating system under the sun with a single framework, programming language and shared codebase. In short, an evolution of .NET Xamarin.Forms.

With preview 12 come some exciting enhancements, let’s talk about a few of them.

Shell Navigation

Xamarin.Forms Shell simplifies mobile app development by offering the essential functionalities that most apps need. Developers can access Shell.Current to issue navigation commands from pretty much anywhere, listen to navigation events, and more. One of the biggest features brought forward is the ability to query parameters.

For example :

private Task NavigateToDetailCommandExecute()
{
    return Shell.Current.GoToAsync($"{nameof(ShowDetailPage)}?Id={Show.Id}");
}

Shell Dependency Injection

Another amazing enhancement is the ability to leverage dependency injection. Starting with Preview 12 developers can now define their dependencies in their main class and use it in their pages

public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>();

            builder.Services
                .AddSingleton<MainViewModel>();

            return builder.Build();
        }
    }
public partial class MainPage
{
    readonly MainViewModel _viewModel;

    public MainPage(MainViewModel viewModel)
    {
        InitializeComponent();

        BindingContext = _viewModel = viewModel;
    }
}

Other improvements

Aside from improvements to Shell, there are quite a few important bug fixes being included with this release. To read more about these head over the the blog post from Microsoft’s David Ortinau.

Before getting started it might be a good idea to do the following…

Before installing Visual Studio 2022 Preview, we highly recommend starting from a clean slate by uninstalling all .NET 6 previews and Visual Studio 2022 previews.

Now, install Visual Studio 2022 Preview (17.1 Preview 3) and confirm .NET MAUI (preview) is checked under the “Mobile Development with .NET workload”.

– David Ortinau, .NET Multi-platform App UI

Overall .NET MAUI is shaping up to be a very exiting platform and an amazing follow up to Xamarin.Forms which was already a very formidable offering on its own. Have you been building your own .NET MAUI powered apps? What has been your experience?

User forum

0 messages