Announcing .NET MAUI Preview 4

David

Image maui weather hero sm

Today we are pleased to announce the availability of .NET Multi-platform App UI (.NET MAUI) Preview 4. Each preview introduces more controls and features to this multi-platform toolkit on our way to general availability this November at .NET Conf. .NET MAUI now has enough building blocks to build functional applications for all supported platforms, new capabilities to support running Blazor on the desktop, and exciting progress in Visual Studio to support .NET MAUI.

Weather ’21

To showcase our progress in Preview 4 for Microsoft Build, we rapidly designed and developed a simple yet beautiful weather app. As we wait for Visual Studio to integrate .NET MAUI productivity features, we began with Xamarin.Forms. We implemented each UI widget and screen with shared styling in a single codebase. After a few hours, we then ported that work to .NET MAUI by making a few, small changes such as adopting the new Microsoft.Maui namespace. The process was painless and quick!

Image macOS maui

We also took the opportunity to show have easy it is to light up deep platform integrations by implementing app actions, an icon in the system tray (status bar), and platform-native notifications all from a single project running on Android, iOS, macOS, and Windows.

private void SetupAppActions()
{
    try
    {
        AppActions.SetAsync(   
            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);
    }
}

Image platform integrations png

Check out the WeatherTwentyOne source code here on GitHub, and our demos from Build 2021.

New Features

Progress continues porting controls and layouts from Xamarin.Forms to the .NET MAUI architecture. In this way, .NET MAUI both is excitingly new and not new at the same time. We have learned much over the past 7 years about how to make cross-platform native UI performant and easy to extend, and we are putting that to work here. For ongoing status of this work visit our GitHub status report.

BlazorWebView

The new BlazorWebView enables you to host a Blazor web application right in your .NET MAUI application and take advantage of seamless native platform features and UI controls. The control can be added to any XAML page and pointed to the root of the Blazor application.

<BlazorWebView 
    HostPage="wwwroot/index.html"
    Services="{StaticResource Services}">
    <BlazorWebView.RootComponent>
        <RootComponent 
            Selector="#app"
            ComponentType="{x:Type local:Main}"
        />
    </BlazorWebView.RootComponent>
</BlazorWebView>

For a deeper look at this powerful integration, read more on our ASP.NET blog.

Splash Screen

On mobile platforms especially you want your first screen to appear as quickly as possible, and this is done by implementing a static splash screen. .NET MAUI now has a single place to describe your splash screen for all platforms that support them.

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

Image splash screens

Any image format may be provided along with a background brush, similar to how we also do app icons. For more advanced scenarios, platform-native splash screen methods all still apply.

Raw Assets

.NET MAUI now makes it very easy to add other assets to your project and reference them directly while retaining platform-native performance. For example, if you want to display a static HTML file in a WebView you can add the file to your project and annotate it as a MauiAsset in the properties.

<MauiAsset Include="Resources\Raw\index.html" />

Tip: you can also use wildcards to enable all files in a directory: Include="Resources\Raw\*"

Then you can use it in your application by filename.

<WebView Source="index.html" />

Visual Studio Productivity

In Visual Studio 16.11 Preview 1 we get a first look at the productivity features for .NET MAUI including new run options for a multi-targeted single project, and the all-new .NET Hot Reload for editing your managed code.

Single Project Run

Single Project 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.

For Single Project, platform-specific application projects are no longer within the solution, thus you will no longer right-click on a project to set it as the startup project.

In the new target debug selector, you will select the platform you are targeting first. After selecting your target platform, you will be given the list of devices you can run your .NET MAUI application on. All of this will be accessible through the Run Menu when you have a .NET MAUI Single Project.

Image run static profiles

The new run menu is the first of a host of changes within Visual Studio to support Single Project applications. We’ll be announcing new features in the upcoming releases, so keep an eye out for updates!

.NET Hot Reload

.NET Hot Reload is a new experience that enables you to make live edits to your .NET MAUI app’s source code while it is running, reducing the number of times you need to rebuild your app.

To start testing this feature install both .NET 6 Preview 4 and Visual Studio 2019 version 16.11 Preview 1. Start your app through the Visual Studio debugger (F5) targeting a WinUI 3 host. Once your app is running, you’ll now have the new option to make code changes and apply them using our new “apply code changes” button as illustrated below.

Image dotnetmaui hotreload winui preview

In coming releases .NET Hot Reload will also be available for Android, iOS, and macOS, and we’ll be integrating XAML Hot Reload and the Live Visual Tree as well.

To learn more about Hot Reload check out Introducing .NET Hot Reload.

Ecosystem Readiness

Image telerik maui

One of the major advantages of using .NET is leveraging a rich ecosystem of controls and libraries for building apps. With Preview 4 the Telerik team has released their first set of controls for .NET MAUI at https://www.telerik.com/maui-ui. Check out their full announcement here.

“Since the very early days of .NET MAUI, our team has been thrilled about the concept behind its multi-platform capabilities! This will be a new era for .NET developers, and we are excited to partner with Microsoft in this journey.” said Stefan Stefanov, Director of Product Management at Progress. “The early preview version of Telerik UI for MAUI provides the .NET developer community with professionally designed, feature rich UI components to kickstart their cross-platform development and deliver stunning applications.”

Other component vendors are also planning .NET MAUI support such as Syncfusion, DevExpress, and GrialKit.

What about your favorite open-source libraries? Dan Siegel has already shared an early preview of Prism, a popular MVVM library.

Image prism tweet

We host a monthly community call to help maintainers bring their libraries to .NET 6 and .NET MAUI. If you would like to participate, send an email to david.ortinau@microsoft.com.

Get Started Today

Check out .NET MAUI today. Get started quickly be running the maui-check .NET tool from the command line to install .NET 6 Preview and all the SDK dependencies you need for developing .NET MAUI apps.

Don’t have maui-check? Run this from your command line:

dotnet tool install -g Redth.Net.Maui.Check

Run maui-check and follow the instructions.

Open Visual Studio 2019 16.11 Preview 1 and create a new .NET Multi-platfrom App UI project.

Image new project dialog

The new solution format includes the multi-targeted project which runs on Android, iOS, and macOS, and the two WinUI projects for Windows. In future releases, the WinUI projects will be absorbed into the multi-targeted project.

The .NET MAUI and AndroidX packages are temporarily on a hosted feed. Once we have those packages bundled as a workload this step will no longer be needed. Run the following terminal commands to add the required source.

dotnet new nugetconfig

dotnet nuget add source -n maui-preview https://aka.ms/maui-preview/index.json

To run for Android, set the multi-targeted project as your startup project and select the Android platform from the Run menu to see your Android emulators.

Android emulators – if this is your first run, you may be asked to create your own emulator before the app will deploy and run.

In coming releases we will enable iOS on Windows support for developing from Visual Studio to your connected iOS device.

For additional information about getting started with .NET MAUI, refer to our wiki documentation on GitHub.

Feedback Welcome

Please let us know about your experiences using .NET MAUI Preview 4 to create new applications by engaging with us on GitHub at dotnet/maui.

For a look at what is coming in future releases, visit our product roadmap.

63 comments

Comments are closed. Login to edit/delete your existing comments

  • 添昊 栾

    what is the 3D solution for .net6? except unity, we need kind of three.js\QT 3D something to draw 3d models in our app. i can see wave engine on the way, but no document and bugs everywhere, will microsoft ship official 3d solutions that can embed in maui that can run on android/ios/windows/mac/web and also for blazor?

      • Paulo Pinto

        That is the problem.

        WPF 3D has no replacement on WinUI or MAUI, telling LOB users to learn low level 3D programing isn’t an option.

        XNA only exists as MonoGame thanks community, as the DirectX team rather supports DirectXTK and C++.

        Apparently we need to rely on third parties for what should be a Microsoft offering, or even force .NET developers to learn C++ to write bindings themselves, also not an option to most shops.

  • Thorsten Sommer

    Great perspective. Unfortunately, Linux support is missing.

  • Jorge Diego Crespo

    I´m trying to test WeatherTwentyOne MAUI example on iOS from MacOS terminal. The application does install in the simulator, but an error occurs when opening. From VS 2019, on Windows, the application is not installed in the simulator, even though Windows is connected to the Mac. It can’t seem to find the .app inside the mac mtbs files, but I have checked and the file exists.
    Both systems are updated through maui-check.

  • Victoria Stahlman

    We also took the opportunity to show how easy it is to light up deep platform integrations by implementing app actions, an icon in the system tray (status bar)…

    This had me super excited as we’re currently struggling with writing a modern windows background service that requires a system tray icon. But alas, looking into the code I found that you’re using a UMP interop library for WPF to achieve this…. Now this is the route we’ve opted to use as well, but it would be nice if with a new UI framework you wouldn’t have to call into ancient WPF to get this feature. Hope a modern solution will be available in the future!

  • DAVID NYAOSO

    I can not debug the WinUI3(package) project. I get a message that I must install Microsoft.NETCore.App 6.0.0-preview.4.21253.7.
    I already installed .NET 6.0.100-preview.4.21255.9.
    Running maui-check –dev informs me that everything is OK.
    Besides, I can run the android project smoothly.
    Also running CLI command: dotnet –list-runtimes indicates that Microsoft.NETCore.App 6.0.0-preview.4.21253.7 is installed!

    How can I get VS 2019 to find the installed Microsoft.NETCore.App 6.0.0-preview.4.21253.7?

    • Rudel, Liam, HL

      I found I had to install the ASP.NET Core runtime before it worked for me.

  • hitesh davey

    Hi @David Ortinau,

    All this MAUI looks good. This is the result of hard work indeed! Thumbs up👍

    Coming from the background of Winforms (with event-driven pattern and 3-tier architecture); I found MVC, MVVM & MVU pattern is workaholic and cumbersome to maintain. Every new release of Visual Studio is becoming more script oriented than first-class designer oriented. If the MAUI team can implement WinForms like WYSIWYG pixel-perfect designer with the option of the traditional event-driven pattern then the MAUI development will take a rocket speed. Pl keep in mind there is a big developer community having good hands-on WinForms (event-driven pattern) than MVVM/MVU patterns (which requires a steep learning curve).

  • 佳琦 刘

    After I enter the command “Maui check”, I will be prompted “the name of the request is valid, but the data of the requested type cannot be found”. I want to know why?

  • sharafudeen

    This is awesome..!!

    Without XAML for UI, can we design Razor with HTML & CSS and target multiple native platform?

  • Dmytro Sokhach

    Hi all,
    On MacOS, VS , facing: “Could not find ‘Xamarin.iOS'”
    or command line:

    /usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/14.5.100-preview.4.638/tools/msbuild/iOS/Xamarin.Shared.targets(892,3): error : Could not find 'Xamarin.iOS'

    Latest XCode is installed and in Options -> Projects -> SDK Locations -> Apple SDK shows success check. (set to: “/Applications/Xcode.app”)

    My project setup is made by:

    dotnet new maui -n HelloMaui

    and then removed Android and iOS from HelloMaui.csproj
    Maybe this is the issue? Is there a way to create project without Android and Windows?