The .NET development team announced the availability of Release Candidate Multi-platform App UI (.NET MAUI) on April 12th. Today we are pleased to announce the availability of the .NET MAUI Release Candidate. The SDK is now complete at the API level, ready to be updated through libraries and made compatible with GA (General Availability), said David Ortinau, chief program manager at Microsoft.
As with other .NET candidate releases, this release is covered by a “Go Live” support policy, meaning .NET MAUI is supported by Microsoft for production applications.
As a framework for building cross-platform apps, .NET MAUI relies on platform SDKs for Android, iOS, macOS, and Windows. These fundamentals are included in this release and ready to use with C# in addition to maximizing code sharing and productivity with .NET MAUI. .NET MAUI uses the latest modern technologies to build native applications on Android, iOS, macOS and Windows by abstracting them into a common framework based on .NET 6.
By default, native apps look like the operating system they belong to, and layouts are fully customized for each device automatically and without additional code. Platform APIs are available directly from C# to access 60+ platform features through a single cross-platform API, including access to things like isolated storage, sensors, geolocation, camera and more, without compromise.
To purchase .NET MAUI RC1 it is required to install or update Visual Studio 2022 Preview to version 17.2 Preview 3. In the installer, confirm that .NET MAUI (Preview) is enabled under Mobile Development with .NET workload. To use .NET MAUI RC1 on a Mac, it is recommended to follow the command line instructions on the wiki. .NET MAUI support in Visual Studio 2022 for Mac will be officially available in an upcoming preview release.
The new .NET MAUI project template now includes a default style sheet in Resourcestyles.xaml with a color mapping and style for all controls. Take the in-between, for example. When launching a new application, these text entries now start with a common theme, but remain true to the platform they are running on.
1 |
Customize controls
One of the things .NET MAUI does to improve the Xamarin.Forms architecture is add low-code hooks to change just about anything. Consider the canonical example of removing the prominent android underline in an input field. What to do if there is no cross-platform underline style because it only exists on Android?
1 | #if ANDROID Microsoft.Maui.Handlers.EntryHandler.Mapper.ModifyMapping(“NoUnderline”, (h, v) => { h.PlatformView.BackgroundTintList = ColorStateList.ValueOf(Colors.Transparent.ToPlatform()); }); #endif |
This code just needs to be executed somewhere at the beginning of your application before the handler is called. First, #if ANDROID is a conditional compiler directive that specifies that this code should only run for Android. In other cases where the control is changed for all platforms, this is not necessary.
Next is access control. The control you are using is a MAUI .NET control. Each property, command, event, etc. of the entry is “mapped” from a “handler” to a platform implementation. To change a mapping, it can be accessed through the handler mapping, e.g. B. Microsoft.Maui.Handlers.EntryHandler.Mapper. From the mapper there are 3 methods:
- PrependToMapping, which runs before the .NET MAUI code.
- ModifyMapping running instead of .NET MAUI code.
- AppendToMapping running after the .NET MAUI code.
In this case it doesn’t matter which of the two is used since it will be called at least once and no other implementation of the entry will touch the native properties that we need to change. Here the code uses ModifyMapping and adds an entry called NoUnderline. Usually the property is the name of an actual property, but in this case Microsoft introduces a new one.
The h in the action is the handler that gives us access to the PlatformView, which in this case is of type Android TextView. At this point, the code works directly with the Android SDK. Since the underlining is no longer necessary, it is possible to implement your own design, for example a frame box like in the old Windows Phone.
C# Hot Reload and XAML Hot Reload transform the way people work and make them more productive. Enter code, save and see changes immediately. Use the latest debugging, intellisense, and testing features in Visual Studio to write better code, faster.
Use one programming language, code base, and project system for all device targets with support for cross-platform resources like images, icons, splash screens, and more.
Hybrid apps that run anywhere
Start building hybrid apps with C# instead of JavaScript today. Share your Blazor web components directly in .NET MAUI apps while still having access to native device features and packages. By using .NET MAUI and Blazor together, it’s possible to reuse a set of web UI components across mobile, desktop, and the web. Use a single development stack that supports all modern workloads with a unified SDK, base class libraries, and toolchain.
Thanks to a common set of APIs available for any kind of .NET 6 application, it is possible to reuse components and libraries more easily. It is also possible to use the hundreds of thousands of packages in the ecosystem to start your development.
Source: microsoft
And you?
What is your opinion on the topic?
See also:
.NET 6 Preview 7: Microsoft revamps project templates and improves some APIs, including C# project templates
Microsoft announces .NET 6 Preview 5, version of framework for building apps, brings improved workloads
Microsoft announces .NET 6, the fastest release ever with support for Apple silicon chips, process-isolated Windows containers, and improved file I/O
.NET 6 would bring up to 40% speed gain over .NET 5, caching and tight loop testing were up to 30% faster