Recently, we released the latest developments in .NET Multi-Platform Application UI (MAUI). In this version, we fully support Visual Studio 2022 Preview 2. This also marked the first time that we released .NET MAUI as a workload installation. Now provides some new features, including gestures, modal pages, view editing, native warnings, flexible layouts, etc. With the adoption of the latest version of the Windows App SDK and Visual Studio plug-in, individual projects continue to be improved. Let's take a deeper look.
.NET Multi-platform Application UI (MAUI):
https://github.com/dotnet/maui
Workload installation
As part of .NET unification, we introduced the concept of SDK workloads to enable specific developer scenarios on top of your installed .NET SDK. In Preview 4, the underlying SDKs for Android, iOS, macOS, and Mac Catalyst were enabled, and now in Preview 6, we have introduced maui, maui-mobile, and maui-desktop workloads. This is the first one that will obtain and install all the SDKs needed to build .NET MAUI applications. If you only want to target mobile devices or desktop devices, you can select them individually.
In the near future, Visual Studio 2022 will include these in its installer. To use them immediately, jump to your favorite CLI. First, see what you have installed:
dotnet sdk check
This will report what was installed through the .NET SDK installer itself. Now look at the additional workloads running:
dotnet workload list
Then install .NET MAUI, you can execute:
dotnet workload install maui
- How about the maui-check dotnet tool? We will continue to update maui-check in each version because it will perform additional verification of your development environment to help you succeed: check OpenJDK, simulator, Xcode, Visual Studio version, etc.
For more information about mobile and desktop workloads, please read the details here.
Read the details here:
https://github.com/dotnet/maui-samples/#dotnet-workload-install-command
New .NET MAUI features
As you can see in our status report, our functions are getting better and better, and we are about to approach full green. Let us focus on some of them.
gesture:
The gesture recognizer allows you to apply tap, pinch, pan, slide, and drag and drop to any view instance. You can easily apply them in XAML:
<Grid>
<Grid.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="2" Command="{Binding OnTileTapped}" />
</Grid.GestureRecognizers>
<!-- Grid content -->
</Grid>
In this example, when the weather widget tile is double-clicked, it will simulate a refresh with fade-out and fade-in animations.
Tailoring:
When you need to block content, you can now add shapes to the clipping area of a layout or view. The most common use is to make circular images.
![image.png](/img/bVcT3KI)
<Image Source="face.png">
<Image.Clip>
<EllipseGeometry RadiusX="80"
RadiusY="80"
Center="80,80" />
</Image.Clip>
</Image>
Local warning:
Each platform has its own way of displaying alerts to users. These can be simple information pop-up windows, simple input forms, or even operation sheets with multiple options to guide users. These can be obtained from any page in the .NET MAUI application.
await DisplayAlert ("Alert", "You have been alerted", "OK");
These are just some of the updated controls and layouts in Preview 6. For a complete list, please check the commit log on GitHub. There will be some radical changes to the layout, borders, corners, and shadows in Preview 7.
In our status report:
https://github.com/dotnet/maui/wiki/Status
Gesture recognizer:
https://docs.microsoft.com/zh-cn/xamarin/xamarin-forms/app-fundamentals/gestures/
pop-up window:
https://docs.microsoft.com/zh-cn/xamarin/xamarin-forms/user-interface/pop-ups#display-an-alert
Simple input form:
https://docs.microsoft.com/zh-cn/xamarin/xamarin-forms/user-interface/pop-ups#display-a-prompt
Operation table:
Single project and window
We have made some updates to individual projects based on developer feedback and Windows support to adopt the latest features. Some of you have been following each version, and we love it! Thank you for providing feedback and interacting with us on GitHub and Discord. So, what changes in Preview 6 do you need to update in your existing solution?
- The NuGet package has been replaced with the .NET MAUI workload (<UseMaui>true</UseMaui> in .csproj).
- The single project solution now nests a single platform in the "platform" folder for a neat organization.
- Update to Windows Application SDK 0.8.1 RC. Use the latest Visual Studio 2022 compatible extension on the market.
.NET MAUI workload:
Single platform nesting:
The latest Visual Studio 2022 compatible extensions:
starting from today
First, install .NET 6 Preview 6. Now add the maui workload using the command above. Also make sure that you have updated to the latest preview version of Visual Studio 2022, or if you are using macOS, you can continue to use CLI and your favorite code editor as we are waiting for the debut of Visual Studio for Mac 2022.
Are you ready? Create a new application from the command line, and then open the solution in Visual Studio 2022.
dotnet new maui -n HelloPreview6
- In future versions of Visual Studio 2022, the .NET MAUI template will appear in the "File"> "New" list. Until then, CLI is your good friend.
Xcode 13 Beta 1 is the new minimum requirement for iOS and macOS. For additional information on getting started with .NET MAUI, please refer to our documentation.
Documentation:
https://docs.microsoft.com/zh-cn/dotnet/maui/get-started/installation
Feedback is welcome
Please interact with us at dotnet/maui on GitHub and let us know about your experience of creating new applications using .NET MAUI Preview 6.
To view the content in future releases, please visit our product roadmap.
If you have any technical questions, please ask on the Microsoft Q&A forum.
dotnet/maui:
https://github.com/dotnet/maui
Product roadmap:
https://github.com/dotnet/maui/wiki/roadmap
Microsoft Q&A:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。