1
头图

Recently, we released the latest development .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 Application SDK and Visual Studio extensions, individual projects continue to be improved. Let's take a deeper look.

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 .

New .NET MAUI features

As you our status report can see, our function more perfect, nears all green, let's focus on some of it.

gesture

gesture recognizer allows you to apply click, pinch, pan, slide, and drag 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 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 window , simple input form , or even operation form with multiple options to guide users. These can be obtained from any page in the .NET MAUI application.

awaitDisplayAlert("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.

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?

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

Feedback is welcome

dotnet/maui on GitHub and let us know your experience of creating new applications using .NET MAUI Preview 6.

To view the content in future versions, please visit our product roadmap .

If you have any technical questions, please ask on the Microsoft Q&A forum.


MicrosoftReactor
109 声望19 粉丝

微软 Reactor 是微软为构建开发者社区而提供的一个社区空间,以“予力多元化社区建设,帮助每一个开发者成就不凡”为使命,旨在通过不定期举办的技术讲座、开发者交流会面及技术沙龙和专题活动,帮助开发者和初创企...