.NET MAUI 11 Preview: Features

.NET Maui Tutorials

As developers are probably aware, .NET MAUI is simply Xamarin.Forms with support for desktop applications. What is nice about this, is that .NET Maui can be used with Visual Studio Code; while experimental, it is still better than Xamarin.Forms, which does not support VS Code.

.NET Maui 11 Updates

.NET MAUI provides a single stack that supports all modern workloads, such as Android, iOS, macOS, and Windows. Each platform’s native features are included in the cross-platform API, with which you can deliver impressive user experiences while sharing even more code. In .NET MAUI, programmers can use a single project to target multiple platforms. This simply means you can quickly deploy to targets such as desktops, emulators, simulators, or physical devices, all with a single click.

In Preview 11 of .NET MAUI, we can expect a few changes, including updates to the Fluent Design System and multi-window apps, to name a few. Let’s have a look at some of the other features we can expect in .NET MAUI.

Read: Best IDEs for .NET Developers

Multi-window Applications

Support for multi-windows applications is really a major update to .NET MAUI, as Xamarin.Forms did not have this capability. To open a new window with .NET MAUI, you can enter the following command:

var newWindow = new Window {
    Page = new NewPage {
        // ...
    }
};
Application.Current.OpenWindow(newWindow);

In the above code example, Application.Current.Windows keeps track of all the windows opened by storing references to all newly created windows.

C# 10 Templates

C# templates using patterns – such as implicit usings, and file-scoped namespaces – will be updated. Item templates for ContentPage and ContentView have also been added. A program with the setting ImplicitUsings (which adds the common global using directives) will have code that resembles the following:

namespace Example;
public static class MauiExample
{
    public static MauiExApp CreateMauiApp()
    {
        var MauiExbuilder = MauiExApp.CreateBuilder();
        MauiExbuilder
            .UseMauiApp()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            });

        return MauiExbuilder.Build();
    }
}

To enable implicit usings, use code like the following in the .csproj file:

<PropertyGroup>
    <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Read: An Introduction to Xamarin

The Fluent Design System

if you are a developer using Windows 11, you may be familiar with the Fluent Design System. For more information on the Fluent Design System, have a look here. The next iteration of .NET MAUI will use the latest styles for controls such as the button, editor, and entry.

The Entry and Editor controls include changes such as the MauiTextBox being renamed to MauiSearchBox, a MauiPasswordTextBox being added, as well as a PasswordEntry control being created. Additions to the MauiButton control include the removal of the MauiButton and the MauiButtonStyle, making use of default ButtonPadding, and ensuring the use of the default Button element and predictable content.

Read more .NET programming tutorials.

Hannes DuPreez
Hannes DuPreez
Ockert J. du Preez is a passionate coder and always willing to learn. He has written hundreds of developer articles over the years detailing his programming quests and adventures. He has written the following books: Visual Studio 2019 In-Depth (BpB Publications) JavaScript for Gurus (BpB Publications) He was the Technical Editor for Professional C++, 5th Edition (Wiley) He was a Microsoft Most Valuable Professional for .NET (2008–2017).

More by Author

Must Read