Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News .NET MAUI Preview 4 Is Here

.NET MAUI Preview 4 Is Here

This item in japanese

.NET Multi-platform App UI (.NET MAUI) Preview 4 is here and brings a lot of interesting stuff. Preview 4 adds a few more features that can be used to build functional apps for all the currently supported platforms; this version also brings the support for running Blazor on the desktop, and progress to support .NET MAUI even more in the Visual Studio IDE.

While presenting new features about .NET MAUI at the Build conference, Microsoft also presented a nice looking weather sample app built entirely using .NET MAUI. The app was first built using Xamarin.Forms, but as they mentioned porting from Xamarin.Forms to .NET MAUI was “painless and quick”.

The Build session about .NET MAUI also covered the quick and easy way to integrate app actions, an icon in the system tray (status bar), and platform-native notifications all from a single project.

The example below shows adding cross-platform AppActions in the .NET MAUI single project. 

private void SetupAppActions()
            new AppAction("current_info", "Check Current Weather", icon: "current_info"),
            new AppAction("add_location", "Add a Location", icon: "add_location")
    catch (System.Exception ex)
        Debug.WriteLine("App Actions not supported", ex);

The Blazor web application can be “hosted” inside of the .NET MAUI application using BlazorWebView. The control for BlazorWebView can be used with any XAML page and point to the root of the Blazor app.

    Services="{StaticResource Services}">
            ComponentType="{x:Type local:Main}"

MauiSplashScreen is a new feature that enables the developers to implement the static screen, also known as a “splash” screen. MauiSplashScreen is static and can be located inside of the single code project for all platforms that support splash screen.

MauiSplashScreen introduces two properties, one for the resource image which will be used, and the Color property for the background. For more advanced scenarios, platform-native splash screen implementation is still available to use.

<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />

Preview 4 also introduced the support for referencing raw assets inside of the project while keeping the platform-native performance. Files can be added to the project and using MauiAsset annotation inside of properties, they will be included. To include all the files located in the folder, the wildcards approach is used.

Visual Studio is one of the main tools for the development of the .NET MAUI apps, so all the new productivity features will also be aligned to support .NET MAUI development even more. One of those is a Single Project Run which: ... introduces a new experience for selecting the target platform and device when running your .NET MAUI applications. These changes simplify the startup process and give you access to all the platforms and devices in a single place.

Since there are no platform-specific projects inside of the solution, there is no way of selecting projects with the “right-click - set startup project” deployment. Using the new target debug selector, the first step is to select the platform which the project is targeting and Visual Studio will provide the options list of the devices which are available to run the .NET MAUI app. The new version and next upgrades will bring even more support to build the Single Project applications.

Alongside Single Project Run, the new tool is .NET Hot Reload. With the support of Hot Reload, the source code now can be modified while the application is running, without the need to manually pause or hit a breakpoint. A supported change can be made while the app is running with the usage of the “apply code changes” button to apply edits.

Next releases of .NET Hot Reload will also bring support for Android, iOS, and macOS, and there is a plan for integrating XAML Hot Reload and the Live Visual Tree as well. More about it and other features of .NET MAUI Preview 4 can be read at the official Microsoft .NET Blog

Rate this Article