.net maui new features

All about .NET MAUI (+15 NEW Features)

Dotnetsafer

.NET MAUI means .NET Multi-Platform App User Interface and allows us to build native desktop and mobile apps with a single code base. .NET MAUI will be running on .NET 6, which will be released in November 2021.

According to Microsoft, .NET MAUI is an evolution of Xamarin Forms with rebuilt controls from the group up for performance and extensibility.

What’s the difference between .NET MAUI and Xamarin Forms?

With .NET MAUI based on .NET 6, the evolution of Xamarin Forms will be integrated into the new world of a single .NET.

With .NET 6 native app development becomes part of .NET like other frameworks such as ASP.NET Core already have with .NET 5.

In .NET MAUI, all your code is in a single project compared to Xamarin Forms, where you had to have a project for every platform. It should reduce complexity and make it an overall better developer experience.

🟢.NET MAUI features: Let’s start with basics

🟢Support

.NET 6 will be released in November 2021 and will be supported for three years, as a Long Term Support (LTS) release. The platform matrix has been significantly expanded compared to .NET 5.

The additions are:

  • Android.
  • iOS.
  • Mac and Mac Catalyst, for x64 and Apple Silicon (AKA “M1”).
  • Windows Arm64 (specifically Windows Desktop).

.NET 6 Debian container images are based on Debian 11 (“bullseye”), which is currently in testing.

🟢 Startup

The .NET MAUI applications will use a Startup class that will allow:

  • Configure method to pipe service registration, handler registration, or application customization processes.
  • Be able to create a custom HostBuilder.

For instance 👇

By default, if you don’t want to customize anything special, or you want to use your own dependency container or something, you can.

🟢 Accessibility

Adding more control and improving the accessibility API to avoid confusion in addition to aligning the behavior in all cases and platforms is one of the priorities in one of the sections with such importance as accessibility.

The concept of SemanticProperties is added. Microsoft are talking about a series of properties that add extra information to Views to allow it to correctly interpret what happens when using the screen reader, or keyboard navigation.

🟢 Workload Installation

As part of .NET unification, Microsoft have introduced the concept of SDK workloads to enable specific developer scenarios on top of the .NET SDK. In previous preview the underlying SDKs for iOSMac CatalystmacOSAndroid were enabled. Now they are introducing the maui, maui-desktop, maui-mobile and workloads. The first will acquire and install all the required SDKs for building .NET MAUI applications.

In the near future Visual Studio 2022 will include these with its installer.

If you want use them, just open a CLI and check what you have installed 👇

Checking dotnet sdk version
Checking dotnet sdk version

After verifying what’s installed, you can see how the additional workloads are running 👇

Checking additional workloads
Checking additional workloads

Finally to install .NET MAUI you need to execute 👇

🟡.NET MAUI features: UI and UX

🟡Shared fonts, images, and app icons

Fonts and images can be placed in one location in your solution and .NET MAUI will enable them to natively work on all platforms you target. These are tracked in your *.csproj as SharedImage and SharedFont.

Both accept wildcards to include all files within a location.

🟡 Font Scaling

All controls across all platforms now have font scaling enabled by default. This means as your application users adjust their text scaling preferences in the OS, your UI will reflect their choice. This produces a more accessible app by default.

.NET MAUI font scaling feature
.NET MAUI font scaling feature

Each control has an added FontAutoScalingEnabled, and it even works with FontImageSource or your font icons. Setting a FontSize is your 100% size, and to lock it in you’ll set FontAutoScalingEnabled =”false" 👇

🟡 New Layouts

Microsoft also tells us that the layouts that have been used in the .NET MAUI are the Xamarin.Forms layouts. They say they started with that approach to quickly get the user interface on screen and focus on completing their library of UI 40 controls.

At the same time, they have been creating streamlined layouts based on a new LayoutManager approach that employs its long 7 years of Xamarin.Forms design training to optimize consistency, performance, and maintainability.

One of the updates that you may have noticed is the leveling out of the default spacing values in these layouts: 0. If you’ve used the legacy layouts, then you already know the different arbitrary values previously set there. Zero sets a clearer expectation and prompts you to set your preferred values that best suit your design needs.

A very easy way is 👇

🟡 Native Alerts

Each platform has a native way of displaying alerts to users. These can be simple informational popups, simple input forms, and even action sheets with multiple options to guide a user.

These are available from any Page in a .NET MAUI application. 👇

.NET MAUI new alert feature
.NET MAUI new alert feature

🟡 Clipping

When you need to mask content you can now add shapes to the clipping region of a layout or view. The most common use for this is to make a circle image.

Clipping function in .NET MAUI
Clipping function in .NET MAUI

🟡Gestures

Gesture recognizers allow you to apply tap, pinch, pan, swipe, and drag-and-drop to any view instance. You can apply them easily in XAML.

.NET MAUI gestures
.NET MAUI gestures

🟡 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.

.NET MAUI splash screen
.NET MAUI splash screen

🟡 New Control Handlers

They have introduced the first controls and properties that implement a new handler approach. These include partial implementations of Button, Label, and Entry, Slider, and Switch. They are now accepting pull requests to fill out complete implementations, and several contributors have already successfully contributed.

The HelloMaui sample application now runs from a single project to macOS, iOS, and Android showcasing the current set of ported controls.

macOS 👇

.NET MAUI Control handlers (macOS)
.NET MAUI Control handlers (macOS)

iOS 👇

.NET MAUI Control handlers (iOS)
v.NET MAUI Control handlers (iOS)

Android 👇

.NET MAUI Control handlers (Android)
.NET MAUI Control handlers (Android)

🟠 .NET MAUI: Better improvements

🟠Mac Catalyst

You can add the following TargetFramework settings to your project to build for macOS desktop, using Mac Catalyst.

🟠Single Project and Windows

Microsoft have made a few updates to single project based on developer feedback and Windows support to adopt the latest features.

.NET MAUI single project and Windows
.NET MAUI single project and Windows

🔴The TOP of .NET MAUI

🔴 .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.

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.

.NET MAUI Hot Reload feature
.NET MAUI Hot Reload feature

🔹 Conclution:

.NET MAUI has only a few months left to go officially. The latest features mentioned by Microsoft in the Previews are very powerful. At the moment we still have a little left to have it and apparently it will greatly facilitate developers to program web, console or mobile applications.

What do you think?🤔

Summary
All about .NET MAUI (+15 NEW Features)
Article Name
All about .NET MAUI (+15 NEW Features)
Description
.NET MAUI means .NET Multi-Platform App User Interface and allows us to build native desktop and mobile apps with a single code base.
Author
Publisher Name
Dotnetsafer
Publisher Logo

0 Comments

Leave a Reply

More great articles

cross site scripting

Cross-Site Scripting (XSS) Vulnerabilities (3 Tips to prevent it)

👨‍💻What is Cross Site Scripting (XSS) Cross Site Scripting (XSS) is a vulnerability that allows an attacker to inject client-side…

Read Story
Blazor Desktop

Blazor Desktop: Like Electron for Javascript but… for .NET?

Blazor Desktop: Electron for .NET? 🤔 Not too long ago, Blazor WebAssembly was just a runtime experiment for C# in a Microsoft…

Read Story
top 5 tools part 2

TOP 5+1 tools for any .NET developer (Part 2)

As we saw in the previous article Top 5 tools for any .NET developer we show the most prominent of Visual Studio. We…

Read Story
Arrow-up