Welcome to the .NET Multiplatform Application UI . This release marks a new milestone in our multi- year journey to unify the .NET platform. Now you and over 5 million other .NET developers have a best-in-class cross-platform UI stack for Android, iOS, macOS, and Windows, complementing the .NET Toolchain (SDK) and Base Class Library (BCL). You can build anything with .NET.
Join us at Microsoft Build 2022 as we walk you through all the updates to build native apps for any device with .NET and Visual Studio, learn more .
This is just the beginning of our journey to create a desktop and mobile application experience that delights .NET developers. For the next phase, the foundation is now laid for the wider .NET ecosystem, bringing plugins, libraries, and services from the .NET Framework and legacy project systems to .NET 6 and SDK-style projects. Available today are:
- AndroidX
https://github.com/xamarin/AndroidX - AlohaKit
https://github.com/jsuarezruiz/AlohaKit - CommunityToolkit.MVVM
https://docs.microsoft.com/windows/communitytoolkit/mvvm/introduction - CommunityToolkit.Maui
https://docs.microsoft.com/dotnet/communitytoolkit/maui/ - CommunityToolkit MauiCompat
https://www.nuget.org/packages/Xamarin.CommunityToolkit.MauiCompat/ - CommunityToolkit Markup.MauiCompat
https://www.nuget.org/packages/Xamarin.CommunityToolkit.Markup.MauiCompat/ - DevExpress
https://www.devexpress.com/maui/ - Facebook
https://github.com/xamarin/FacebookComponents - FreshMvvm.Maui
https://www.nuget.org/packages/FreshMvvm.Maui - Google APIs for iOS
https://github.com/xamarin/GoogleAPIsForiOSComponents - Google Play Services Client Libraries
https://github.com/xamarin/GooglePlayServicesComponents - GrialKit
https://grialkit.com/grial4-special-ms-build-release - MauiAnimation
https://github.com/jsuarezruiz/MauiAnimation - Microsoft.Maui.Graphics
https://docs.microsoft.com/dotnet/maui/user-interface/graphics/ - MR.Gestures
https://www.mrgestures.com/ - Prism.Maui
https://www.nuget.org/packages/Prism.Maui/ - Plugin.Fingerprint
https://www.nuget.org/packages/Plugin.Fingerprint/ - Plugin.InAppBilling
https://www.nuget.org/packages/Plugin.InAppBilling/ - Plugin.StoreReview
https://www.nuget.org/packages/Plugin.StoreReview/ - Plugin.ValidationRules
https://www.nuget.org/packages/Plugin.ValidationRules - ReactiveUI.Maui
https://www.nuget.org/packages/ReactiveUI.Maui/ - Shiny
https://shinylib.net/ - SkiaSharp
https://github.com/mono/SkiaSharp - Syncfusion
https://www.syncfusion.com/maui-controls - Telerik UI for .NET MAUI
https://www.telerik.com/maui-ui?utm_medium=referral&utm_source=microsoftblogs&utm_campaign=maui-awareness-ms-ga-announcement - TemplateUI
https://github.com/jsuarezruiz/TemplateUI - User Dialogs
https://github.com/aritchie/userdialogs
For help migrating a library to .NET 6, check out a recent blog post detailing the experience of Michael Rumpler (MR.Gestures) and Luis Matos (Plugin.ValidationRules) migrating to the .NET MAUI library.
The current 18-month release schedule fully supports .NET MAUI workloads and will be served at the same cadence as .NET. Our ongoing focus on .NET MAUI remains quality, addressing known issues , and prioritizing issues based on your feedback. This also includes the workloads we deliver for building apps specifically for Android, Android Wear, CarPlay, iOS, macOS, and tvOS that use native toolkits directly from .NET, as well as support libraries for AndroidX, Facebook, Firebase, Google Play Services, and Skiasharp.
With .NET MAUI, you can achieve a no-compromise user experience while sharing more code than ever before. .NET MAUI utilizes native UI with major app toolkits provided by each platform, modern developer productivity and our fastest mobile platform to date.
Native UI, no compromise
The main goal of .NET MAUI is to enable you to deliver the best app experience designed specifically for each platform (Android, iOS, macOS, and Windows), while enabling you to create a consistent brand experience with rich styling and graphics. Out of the box, each platform looks and behaves the way it should, without any additional widgets or styles to mimic. For example, .NET MAUI on Windows is powered by WinUI 3 , the main native UI component that ships with the Windows App SDK .
Build your applications using C# and XAML from a rich toolkit of over 40 controls, layouts, and pages. On the Xamarin shoulders of mobile controls, .NET MAUI adds support for multi-window desktop applications, menu bars and new animation features , borders, corners, shadows, graphics, and more. Oh, and the new BlazorWebView that I'll highlight below.
Read more about controls in the .NET MAUI documentation: Pages, Layouts, and Views .
Accessibility takes precedence
A major advantage of using native UI is inherited accessibility support, which we can build on top of Semantic Services , making it easier than ever to create highly accessible applications. We work closely with our clients to redesign the way we develop accessibility. From these conversations, we designed .NET MAUI Semantic Services to control:
- Attributes such as description, prompt, and title level
- focus
- screen reader
- Automation Properties Read more about Accessibility Semantic Services in the .NET MAUI documentation.
Beyond the User Interface
.NET MAUI provides simple APIs to access each platform's services and features, such as accelerometers, application operations, file systems, notifications, and more. In this example, we configure Application Actions to add menu options for the application icon on each platform:
AppActions.SetAsync(
new AppAction("current_info", "Check Current Weather", icon: "current_info"),
new AppAction("add_location", "Add a Location", icon: "add_location")
);
Read more about access desk services and features in the .NET MAUI documentation.
Easy to customize
Whether you're extending the functionality of .NET MAUI controls or building new platform capabilities, .NET MAUI's architecture is designed to be extensible, so you'll never hit a wall. Take, for example, the Entry control - a canonical example of rendering different controls on one platform. Android draws an underline below the text field, and developers often want to remove the underline. With .NET MAUI, customizing every entry in the entire project is just a few lines of code:
#if ANDROID
Microsoft.Maui.Handlers.EntryHandler.Mapper.ModifyMapping("NoUnderline", (h, v) =>
{
h.PlatformView.BackgroundTintList = ColorStateList.ValueOf(Colors.Transparent.ToPlatform());
});
#endif
This is a good example of a new map platform control recently created by Cayas Software. The blog post demonstrates creating a handler for a control, implementing it for each platform, and then making it available by registering the control in .NET MAUI.
.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(MapHandlerDemo.Maps.Map),typeof(MapHandler));
})
Read more about customizing controls with handlers in the .NET MAUI documentation
Modern developer productivity
.NET is not just a technology to build anything, we want .NET to use common language features, patterns and practices, and tools to improve your productivity.
.NET MAUI uses new C# 10 features introduced in .NET 6, including the global using statement and file-scoped namespaces - great for reducing clutter and clutter in your files. With a "single project" focus, .NET MAUI takes multi-targeting to the next level.
In the new .NET MAUI project, the platforms are in a subfolder, focusing on the application where you spend most of your effort. In your project's Resources folder, you can manage your application's fonts , images , application icons , splash screens , raw resources, and styles in one place . .NET MAUI will be optimized for the unique needs of each platform.
Multi-Project vs Single-Project: Building your solution with separate projects for each platform is still supported, so you can choose a single-project approach to developing your application.
.NET MAUI uses the builder pattern popular with the Microsoft.Extensions library in ASP.NET and Blazor applications as a single place to initialize and configure the application. From here, you can provide your fonts for .NET MAUI, leverage platform-specific lifecycle events, configure dependencies, enable specific features, enable vendor control toolkits, and more.
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureServices()
.ConfigureFonts(fonts =>
{
fonts.AddFont("Segoe-Ui-Bold.ttf", "SegoeUiBold");
fonts.AddFont("Segoe-Ui-Regular.ttf", "SegoeUiRegular");
fonts.AddFont("Segoe-Ui-Semibold.ttf", "SegoeUiSemibold");
fonts.AddFont("Segoe-Ui-Semilight.ttf", "SegoeUiSemilight");
});
return builder.Build();
}
}
public static class ServicesExtensions
{
public static MauiAppBuilder ConfigureServices(this MauiAppBuilder builder)
{
builder.Services.AddMauiBlazorWebView();
builder.Services.AddSingleton<SubscriptionsService>();
builder.Services.AddSingleton<ShowsService>();
builder.Services.AddSingleton<ListenLaterService>();
#if WINDOWS
builder.Services.TryAddSingleton<SharedMauiLib.INativeAudioService, SharedMauiLib.Platforms.Windows.NativeAudioService>();
#elif ANDROID
builder.Services.TryAddSingleton<SharedMauiLib.INativeAudioService, SharedMauiLib.Platforms.Android.NativeAudioService>();
#elif MACCATALYST
builder.Services.TryAddSingleton<SharedMauiLib.INativeAudioService, SharedMauiLib.Platforms.MacCatalyst.NativeAudioService>();
builder.Services.TryAddSingleton< Platforms.MacCatalyst.ConnectivityService>();
#elif IOS
builder.Services.TryAddSingleton<SharedMauiLib.INativeAudioService, SharedMauiLib.Platforms.iOS.NativeAudioService>();
#endif
builder.Services.TryAddTransient<WifiOptionsService>();
builder.Services.TryAddSingleton<PlayerService>();
builder.Services.AddScoped<ThemeInterop>();
builder.Services.AddScoped<ClipboardInterop>();
builder.Services.AddScoped<ListenTogetherHubClient>(_ =>
new ListenTogetherHubClient(Config.ListenTogetherUrl));
return builder;
}
}
Read more about launching applications with MauiPrograms and individual projects in the .NET MAUI documentation.
Bringing Blazor to Desktop and Mobile
.NET MAUI is also great for web developers who want to get involved with native client applications. .NET MAUI integrates with Blazor so you can reuse existing Blazor Web UI components directly in native mobile and desktop applications. With .NET MAUI and Blazor, you can reuse your web development skills to build cross-platform native client applications and build a single UI across mobile, desktop and web.
.NET MAUI executes Blazor components natively on the device (no WebAssembly required) and renders them to embedded web view controls. Because your Blazor components are compiled and executed in the .NET process, they are not limited to the web platform and can take advantage of any native platform functionality, such as notifications, Bluetooth, geolocation and sensors, file systems, and more. You can even add native UI controls alongside the Blazor Web UI. Here's a brand new hybrid app: Blazor Hybrid!
Getting started with .NET MAUI and Blazor is easy: just use the included .NET MAUI Blazor application project template.
This template is all set up so you can start building .NET MAUI Blazor applications using HTML, CSS, and C#. The Blazor Hybrid tutorial for .NET MAUI walks you through building and running your first .NET MAUI Blazor application.
Alternatively, add the BlazorWebView control to an existing .NET MAUI application wherever you want to start using Blazor components:
<BlazorWebView HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
<RootComponent Selector="#app" ComponentType="{x:Type my:Counter}" />
</BlazorWebView.RootComponents>
</BlazorWebView>
Blazor Hybrid support is now also available for WPF and Windows Forms , so you can start modernizing your existing desktop applications to run on the web or cross-platform with .NET MAUI. The BlazorWebView control for WPF and Windows Forms is available on NuGet. Check out the Blazor Hybrid tutorial for WPF and Windows Forms to learn how to get started.
To learn more about Blazor Hybrid's support for .NET MAUI, WPF, and Windows Forms, check out the Blazor Hybrid documentation.
Optimized for speed
.NET MAUI is designed for performance. You've told us that it's important to have your app launch as quickly as possible, especially on Android. UI controls in .NET MAUI implement a lean, decoupled handler mapper pattern over native platform controls. This reduces the number of layers in UI rendering and simplifies control customization.
Layouts in .NET MAUI have been designed to use a consistent manager pattern to optimize metrics and schedule loops to render and update your UI faster. In addition to StackLayout, we also showcased layouts that are pre-optimized for specific scenarios, such as HorizontalStackLayout and VerticalStackLayout.
From the very beginning of this journey, we set a goal of improving startup performance and maintaining or reducing application size when transitioning to .NET 6. At GA we have achieved 34.9% improvement in .NET MAUI and 39.4% improvement in .NET for Android. These gains extend to complex applications as well; the .NET Podcast sample application took 1299ms to start and 814.2ms at GA, a 37.3% improvement since Preview 13.
These settings are enabled by default to provide release builds with these optimizations.
Stay tuned for our in-depth blog post on achieving these results.
starting from today
To start using .NET MAUI on Windows, install Visual Studio 2022 Preview or update it to version 17.3 Preview 1.1. In the installer, select the workload ".NET Multi-platform App UI development".
To use .NET MAUI on Mac, install the new Visual Studio 2022 Preview for Mac (17.3 Preview 1).
Visual Studio 2022 will support the GA .NET MAUI tools later this year. On Windows today, you can speed up your development cycle with XAML and .NET Hot Reload and powerful editors for XAML, C#, Razor, CSS, and more. Using XAML Live Preview and Live Visual Tree, you can preview, align, inspect your UI, and edit it while debugging. The new single-project experience for .NET MAUI now includes project property pages, providing a visual editing experience to configure multi-platform targeting for your app.
On Mac, you can now load single-project and multi-project .NET MAUI solutions to debug with the beautiful new native Visual Studio 2022 for Mac experience. Additional features to improve your productivity developing .NET MAUI applications will be available in subsequent preview releases.
We recommend starting updating your library to .NET MAUI and creating a new .NET MAUI project now. Before diving into converting your Xamarin project to .NET MAUI, review your dependencies, Visual Studio's support status for .NET MAUI, and known issues published to determine the correct time to convert. Keep in mind that Xamarin will continue to be supported by the Modern Lifecycle Policy , which states 2 years from the last major release.
resource
- .NET MAUI - Workshop
https://github.com/dotnet-presentations/dotnet-maui-workshop - Build your first .NET MAUI application
https://dotnet.microsoft.com/learn/maui/first-app-tutorial/intro - Documentation
https://docs.microsoft.com/dotnet/maui - known issues
https://github.com/dotnet/maui/wiki/Known-Issues - Microsoft Learning Path
https://docs.microsoft.com/learn/paths/build-apps-with-dotnet-maui/ - Q&A Forum
https://docs.microsoft.com/answers/topics/dotnet-maui.html - Release Notes
https://github.com/dotnet/maui/releases/tag/6.0.312 - Example
https://github.com/dotnet/maui-samples - Support Policy – .NET MAUI
https://dotnet.microsoft.com/platform/support/policy/maui - Support Policy – Xamarin
https://dotnet.microsoft.com/platform/support/policy/xamarin
we need your feedback
We would love to hear from you! When you encounter any issues, please file a report at dotnet/maui on GitHub.
generalize
With .NET MAUI , you can build native apps for Android, iOS, macOS, and Windows from a single codebase using the same productivity patterns practiced in .NET. .NET MAUI's thin and separated UI and layout architecture and single-project capabilities allow you to focus on one application rather than juggling the unique needs of multiple platforms simultaneously. With .NET 6, we're delivering performance improvements not only for Android, but for all platform targets.
Less platform code, more shared code, consistent standards and patterns, lightweight and high-performance architecture, mobile and desktop native experiences—this is just the beginning. We look forward to seeing the library and wider ecosystem work with .NET MAUI in the coming months to define a new era of cross-platform application development for .NET developers, enabling you and your organization to achieve more .
Follow Microsoft China MSDN to learn more
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。