.NET Multi-platform Application UI (.NET MAUI) can use a single code base to build native client applications for Windows, macOS, iOS, and Android, and provide native containers and controls for the Blazor hybrid solution. .NET MAUI is a framework in Visual Studio that abstracts the native UI frameworks already available-WinUI for Windows, Mac Catalyst for macOS/iPadOS, iOS and Android. Although it is not another native UI framework, there is still a lot of work needed to provide the best development and runtime experience on these devices.
The .NET team has been working hard with the community, and we are committed to its release. Unfortunately, .NET MAUI will not be released with .NET 6 GA in November. We want to provide our users with the best experience, performance and quality on the first day, and for this, we need to postpone the timetable. Our current goal is to launch .NET MAUI at the beginning of the second quarter of 2022.
At the same time, we will continue to enhance Xamarin and recommend it for building production mobile applications, and continue to release monthly previews of .NET MAUI. All the features we plan to provide for .NET MAUI will be available when .NET 6 is released in November, but we will continue to work hard to improve quality and resolve customer feedback. We encourage you to try the preview. The .NET Upgrade Assistant will also support upgrading Xamarin projects to .NET MAUI.
.NET 6 RC1 is the version before the final version, which means you can use it in production and get support. This does not include the .NET MAUI package. The next version of the .NET MAUI package will show a "preview" in the version when .NET 6 RC2 is released.
Thank you for all the feedback, contributions, and excitement you shared with us during this journey. Please continue to publish, and we look forward to a high-quality version early next year. Now let us look at some of the new features in this version.
.NET MAUI Preview 8 Highlights
The September preview of .NET MAUI completed some important Visual Studio integrations, namely, installing .NET MAUI as a workload in the Visual Studio 2022 installer and folding the Windows platform into our single, multi-target project. With Visual Studio 2022 Preview 4, you can now use wider hot reload support through C# and XAML, as well as the new XAML real-time preview panel to create an efficient and focused development environment. In the .NET MAUI SDK itself, Preview 8 includes updates to the application startup mode, the ability to extend handlers, and various other new control functions as we approach the functional integrity.
Visual Studio 2022 Productivity
When you install Visual Studio 2022, you can now check .NET MAUI (preview) in mobile development using .NET workloads. This will introduce .NET 6 and optional workload dependencies: Android, iOS, and Mac Catalyst. When targeting the desktop, you also need to choose desktop development using .NET, UWP, and desktop development using C++ workloads.
After installation, the .NET MAUI template and the features of Visual Studio are available. The real-time preview will mirror your running application in the panel in the Visual Studio window, and you can dock it wherever it is most convenient. The panel supports zooming in and out to focus on every detail of the UI, a guide for aligning elements on the horizontal and vertical axis, and on some platforms, you can hover and select UI elements to get size and distance information.
XAML hot reload is now available for Android, iOS (via hot restart or remote build host on Windows) and Windows. .NET Hot Restart also works with XAML Hot Reload on Android, iOS and Windows.
When creating a new project, you will now see the Windows platform alongside Android, iOS, and Mac Catalyst in the Platforms folder. To use Windows, you first need to install the Windows App SDK extension for Visual Studio 2022, and then uncomment the TargetFramework node at the top of the csproj file. In a future version, this will be provided by default through a pre-installed extension for .NET MAUI.
.NET MAUI SDK update
The most significant update when you migrate an existing application is how we implemented the .NET Host Builder pattern. We are now consistent with how ASP.NET and Blazor use the MauiProgram class that creates and returns MauiApp. Now every platform calls MauiProgram.CreateMauiApp. Compare the existing project with the new template or pull request to see these changes to Android/MainApplication.cs, iOS/AppDelegate.cs, and macCatalyst/AppDelegate.cs.
Example MauiProgram:
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
return builder.Build();
}
}
Android example MainApplication:
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Android update
Android 12 (API 31) is now the default version of .NET 6 applications built for Android. To use Android 12, you need manually install JDK 11 . Once we update the Android tools in Visual Studio to use JDK 11, we will bundle this dependency with .NET MAUI by default. Before that, JDK 11 may adversely affect the Android designer, SDK manager, and device manager.
Android projects now use MaterialTheme by default. Make sure that Platforms/Android/MainActivity.cs specifies @style/Maui.SplashTheme or you may encounter runtime errors on Android. For example, check updated .NET MAUI template .
Other changes
Other notable changes include:
- The "Request" suffix has been removed for MinHeightRequest, MaxHeightRequest, MinWidthRequest, MaxWidthRequest, and the layout system now treats them as true values
- A simplified way to attach behavior to any control mapper – #1859
- Various improvements to the Shell theme style
- As Android # 2027 and iOS # 2029 added RefreshView
- Add absolute layout #2136
- Added right to left (RTL) FlowDirection #948
- Add Button.Icon ImageSource #2079
today
Are you ready? Open Visual Studio 2022 and create a new project. Search and select .NET MAUI.
For more information on getting started with .NET MAUI, please refer to our document .
welcome feedback
Visual Studio 2022 is quickly enabling the new features of .NET MAUI. When you encounter any problems with debugging, deployment, and editor-related experience, please use the "Help"> "Send Feedback" menu to report your experience.
Please dotnet/maui to let us know your experience of creating new applications with .NET MAUI.
To view the content in future versions, please visit our product roadmap , and to understand the status of functional integrity, please visit our status wiki .
Welcome to follow the Microsoft China MSDN subscription account for more latest releases!
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。