Announcing .NET MAUI Preview 7

David

.NET 6 Preview 7 is now available, and we have introduced all new layouts for .NET Multi-platform App UI (MAUI). This is a significant change for performance and reliability. We are excited to also introduce some new accessibility focused capabilities based on the new SemanticService, font scaling options, compatibility support for Xamarin.Forms Effects, and more.

Grid landscape

New Layouts

Up to now the layouts you’ve been using in .NET MAUI are the Xamarin.Forms layouts that were made aware of how to size and position both renderers and the new handler based controls. We began with this approach in order to quickly put UI on screen and focus our efforts on completing our library of UI 40 controls, and to prove out our ability to be compatible with projects migration from Xamarin.Forms. At the same time, we have been building optimized layouts based on a new LayoutManager approach employing our 7 years of Xamarin.Forms layout learning to optimize for consistency, performance, and maintainability.

In this preview, the old layouts are now only to be found in the Microsoft.Maui.Controls.Compatibility namespace, and the new layouts are enabled by default as:

StackLayout now wraps two layouts focused on horizontal and vertical orientations. We recommend choosing the one that fits your layout need. The StackLayout still has an orientation property you can set, and in some cases this is essential when your adaptive layouts my change orientation based on screen size or device idiom.

Each layout has an accompanying LayoutManager responsible for measuring and positioning views. The Measure method takes height and width constraints, and is responsible for measuring all of hte layout’s children. The ArrangeChildren then sets the size and position of each view according to the rules of the layout. For very advanced cases, you may override the CreateLayoutManager method of a layout to provide a custom implementation of ILayoutManager.

One of the immediate updates you’ll noticed is the leveling of default spacing values on these layouts: 0. If you have used the legacy layouts, then you are already aware of different, arbitrary values previously set there. Zero sets a more clear expectation, and directs you to set your preferred values that meet your design needs. For convenience, set these starting values in your global styles:

<ResourceDictionary>
    <Style TargetType="StackLayout">
        <Setter Property="Spacing" Value="6"/>
    </Style>

    <Style TargetType="Grid">
        <Setter Property="ColumnSpacing" Value="6"/>
        <Setter Property="RowSpacing" Value="6"/>
    </Style>
</ResourceDictionary>

AbsoluteLayout and RelativeLayout now exist only in the compatibility namespace, and we recommend you closely consider whether you really need to use them or not. Where possible, use one of the layouts listed above. In the meantime, you can update your code to use them by adding the new namespace, and prefixing your XAML references:

<ContentPage
    xmlns:cmp="clr-namespace:Microsoft.Maui.Controls.Compatibility;assembly=Microsoft.Maui.Controls"
    ...
    >
    <cmp:AbsoluteLayout>
        ...
    </cmp:AbsoluteLayout>
</ContentPage>

The .NET Upgrade Assistant is being updated for all of these changes, and we’ll do our best to guide you through them, if not handle them for you during the upgrade process.

We will be giving a lot of focus to polishing up these new layouts through the next several sprints, so please give them a look and file any issues you observe as you explore using them.

Accessibility Changes and Improvements

We meet monthly with several developers across a variety of companies heavily invested in delivering applications that meet the highest accessibility rating. From these meetings we have made a few changes and additions to our accessibility support making it easier for everyone to product accessible apps.

TabIndex and IsTabStop Removed

TabIndex and IsTabStop properties were introduced in Xamarin.Forms to help developers control the order in which UI elements would be read by a screen reader. In practice, they ended up being confusing and not meeting that need. In .NET MAUI we recommend a thoughtful design approach that orders your UI as you would want it to be read, rather than looking for programmatic ways to manipulate the structure of your interface. For cases when you must take control over the order, we recommend the community toolkit’s SemanticOrderView which will be available in the .NET MAUI version of the same.

SetSemanticFocus and Announce

Part of the new SemanticExtensions class, we have added a new SetSemanticFocus method allows you to move screen reader focus to a specific element. Compare this to VisualElement.Focus which sets input focus.

<VerticalStackLayout>
    <Label
        Text="Explore SemanticExtensions below"
        TextColor="RoyalBlue"
        FontAttributes="Bold"
        FontSize="16"
        Margin="0,10"/>
    <Button
        Text="Click to set semantic focus to label below"
        FontSize="14"
        Clicked="SetSemanticFocusButton_Clicked"/>
    <Label
        x:Name="semanticFocusLabel"
        Text="Label receiving semantic focus"
        FontSize="14"/>
</VerticalStackLayout>
private void SetSemanticFocusButton_Clicked(object sender, System.EventArgs e)
{
  semanticFocusLabel.SetSemanticFocus();
}

Within Essentials we have added another new method, Announce, which sets the text to be announced by the screen reader. On a button click, for example, you can trigger the following important message to be read:

void Announce_Clicked(object sender, EventArgs e)
{
  SemanticScreenReader.Announce("Make accessible apps with .NET MAUI");
}

Font Scaling

All controls across all platforms now have font scaling enabled by default. This means as your application users adjust their text scaling preferences in the OS, your UI will reflect their choice. This produces a more accessible app by default.

the same UI at different text scaling

Each control has an added FontAutoScalingEnabled, and it even works with FontImageSource for your font icons. Setting a FontSize is your 100% size, and to lock it in you’ll set FontAutoScalingEnabled="false".

<VerticalStackLayout>    
    <Label 
        Text="Scaling disabled" 
        FontSize="18"
        FontAutoScalingEnabled="False"/>
    <Label 
        Text="Scaling enabled" 
        FontSize="18"/>
</VerticalStackLayout>

Be sure to review your screens and adjust styling as needed to make sure they are usable at all sizes.

Additional Highlights

Also in this release are several other notable additions.

  • We have added support for Effects, which will support projects upgrading from Xamarin.Forms. #1574.
  • AppThemeBinding improvements for supporting dark and light theme modes #1657
  • ScrollView handler #1669
  • Android Shell ported to core #979
  • Shell navigation passing complex objects #204
  • Visual Tree Helper added for XAML Hot Reload #1845
  • Switch to System.ComponentModel.TypeConverter #1725
  • Window lifecycle events #1754
  • Page navigation events #1812
  • CSS prefix updated to -maui #1877

For a full set of changes, review the branch comparison.

Get Started Today

First thing’s first, install .NET 6 Preview 7. Next add the maui workload using maui-check. Also make sure you have updated to the latest preview of Visual Studio 2022.

In future versions of Visual Studio 2022 .NET MAUI will be installed alongside other workloads. For now maui-check from the CLI is our recommendation for installing everything you need.

Ready? Open Visual Studio 2022 Preview 3 and create a new project. Search for and select .NET MAUI.

Visual Studio 2022 new project dialog, Announcing .NET MAUI Preview 7

For additional information about getting started with .NET MAUI, refer to our documentation.

Feedback Welcome

Visual Studio 2022 previews are rapidly enabling new features for .NET MAUI. As you encounter any issues with debugging, deploying, and editor related experiences, please use the Help > Send Feedback menu to report your experiences.

At the time of release, we are troubleshooting the latest Windows App SDK Single-project MSIX extension for Visual Studio 2022 and .NET MAUI to address a failure to debug. You can successfully deploy the Windows app directly and run it from the Start menu.

Please let us know about your experiences using .NET MAUI Preview 7 to create new applications by engaging with us on GitHub at dotnet/maui.

For a look at what is coming in future releases, visit our product roadmap, and for a status of feature completeness visit our status wiki.

69 comments

Comments are closed. Login to edit/delete your existing comments

  • Asad Mehmood

    Hi @David, interested to know about App (cold) startup time on Android for MAUI. For last couple of previews, it was almost same as Xamarin Forms GA. Does your team have any plans to significantly improve this before MAUI GA? Can we expect any numbers in percentage?
    Xamarin forms are usable on Flagship phones but on mid-range Androids the Hello-World App take more than 10 seconds to start. Answer to this question is very important to us to understand clear picture. Thank you for the good work.

  • Steve Wasielewski

    Get this error when trying to run maui-check and I have updated to the latest .net core preivew:
    Error: Error resolving type specified in JSON ‘DotNetCheck.Manifest.NuGetFeedVariableMapper, MauiCheck’. Path
    ‘check.variableMappers[0].$type’, line 9, position 74.

  • Renee GA

    Getting this error when trying to run maui-check

    Fix failed – Workload Repair failed: dotnet workload repair --source "https://api.nuget.org/v3/index.json" --source
    "https://pkgs.dev.azure.com/dnceng/public/_packaging/6.0.100-preview.7.21379.14-shipping-1/nuget/v3/index.json" --source
    "https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" --source
    "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json"

    • Gerald VersluisMicrosoft employee

      Try running dotnet workload install maui manually, I think that should work and then maui-check to install the rest of the requirements

      • Paul Sorauer

        Hi @Gerald

        Manual installation fails. When running

        dotnet workload install maui

        I get the following:

        Workload installation failed: The JSON value could not be converted to Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadPackId. Path: $.Id | LineNumber: 0 | BytePositionInLine: 52.

        Users of the maui-check tool seem to be the same error as I did here when running the dotnet workload command. If it’s of interest, you can see the isssue here: https://github.com/Redth/dotnet-maui-check/issues/105

        • Robert Sundström

          I get the same. First I assumed my installation was broken, since I tried an RC1 build.

          I need to find a way to clean-up my SDKs anyway.

  • Renee GA

    Ok, a more specific error is:

    Workload repair failed: The JSON value could not be converted to Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadPackId. Path: $.Id | LineNumber: 0 | BytePositionInLine: 25.

    • Renee GA

      ok, I manually added missing stuff with dotnet workload install maui and dotnet workload install ios. And I successfully got vs 2022 to show the MAUI template. I created new MAUI project with the template, and successfully complied the 2 projects. Now I got a new issue that I cannot run the WinUI project even if it compiled successfully. The visual studio just say “unable to start debugging” “unable to run the project”. Is there anything I need to do to make WinUI work?

      For the record. there is an exclamation mark on my dependency icon of .WinUI project. UniversalCRT.Debug, VCLibs, VCLibs.Desktop all have exclamation marks on them.

      • David OrtinauMicrosoft employee

        Yes, we need a VS fix to address the Windows issue. It’s in progress and we hope to be able to service that very soon. I mentioned a potential workaround at the end of the blog post you can try. Or wait for an update.

        • Paul Sorauer

          I know you guys are working hard and this is not a criticism at all, but just to let you know this is very painful for me and I can’t be the only one…

          My ‘deployed’ app is crashing during the startup routine (doesn’t happen when running on mobile) but I obviously can’t attach the debugger until the app loads and for whatever reason my try catch block isn’t firing and so I can’t even capture the exception and put it in the logs.

          Catch 22. I can’t move forward with the WinUI version. 😥

        • Alex Fanat

          I have some context to add to this, that when trying to run the built WinUI assembly with the dotnet CLI, it will actually work and run, but it will crash at runtime saying that something with COM is not setup correctly and that a class needs to be registered, but was not. Below is the error text.

          Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
           ---> System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
             at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName) in Microsoft.WinUI.dll:token 0x600002b+0x6e
             at Microsoft.UI.Xaml.Application._IApplicationStatics..ctor() in Microsoft.WinUI.dll:token 0x600aeb8+0x1c
             at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x60006c8+0x3e
             --- End of inner exception stack trace ---
             at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x60006c8+0x4e
             at System.Activator.CreateInstance[T]() in System.Private.CoreLib.dll:token 0x60009ed+0x0
             at WinRT.WeakLazy`1.get_Value() in Microsoft.WinUI.dll:token 0x6000021+0x20
             at Microsoft.UI.Xaml.Application._IApplicationStatics.get_Instance() in Microsoft.WinUI.dll:token 0x600aeb9+0x0
             at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback) in Microsoft.WinUI.dll:token 0x600ae86+0x0
             at Blazor_MAUI_Sandbox.WinUI.Program.Main(String[] args) in C:\Users\Alex\Documents\Structured\Source Code\Blazor MAUI Sandbox\Blazor MAUI Sandbox\Blazor MAUI Sandbox.WinUI\obj\Debug\net6.0-windows10.0.19041\win-x64\Platforms\Windows\App.g.i.cs:line 26

          And below here is the code being referred to in the trace.

          global::Microsoft.UI.Xaml.Application.Start((p) => {
              var context = new global::Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext(global::Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread());
              global::System.Threading.SynchronizationContext.SetSynchronizationContext(context);
              new App();
          });
  • Luis Linares

    Hello! i have installed the visual studio 2022 preview 3 and everything looks good! The installation was successfull!

    Now, I’m trying to install MAUI with this new version but i got an error 🙁

    I Ran maui-check and i got everything OK, but when i try to install maui, i recieve the message:


    Installing pack Microsoft.Maui.Controls.Runtime.win version 6.0.100-preview.7.1345…
    Writing workload pack installation record for Microsoft.Maui.Controls.Runtime.win version 6.0.100-preview.7.1345…
    Installing pack Microsoft.Maui.Essentials.Ref.win version 6.0.100-preview.7.1345…
    Writing workload pack installation record for Microsoft.Maui.Essentials.Ref.win version 6.0.100-preview.7.1345…
    Installing pack Microsoft.Maui.Essentials.Runtime.win version 6.0.100-preview.7.1345…
    Writing workload pack installation record for Microsoft.Maui.Essentials.Runtime.win version 6.0.100-preview.7.1345…
    Garbage collecting for SDK feature bands 6.0.100…

    Workload installation failed: The JSON value could not be converted to Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadPackId. Path: $.Id | LineNumber: 0 | BytePositionInLine: 40.

    • Damian Wyka

      Same here. In prev 6 i had issues for more than 2 weeks with installing single project extension (500 error) never fixed until prev 7 now maui workload installer is broken and i still cant test maui ugh…

    • David OrtinauMicrosoft employee

      There was a change in the manifest json a version or two back, so if you have previously installed .NET 6 and MAUI then this can happen. Remove other versions (typically in Program Files\dotnet), update maui-check to 0.7.3 or newer, and try again.

      • Trevor Tirrell

        I’m not clear what needs removed.

        With I run dotnet workload install maui with both the ..\sdk\6.0.100-preview.6.21355.2 and 7.21379.14 and folders and I get an error:
        Updated advertising manifest microsoft.net.workload.mono.toolchain.
        Garbage collecting for SDK feature bands 6.0.100…
        Uninstalling workload pack version 6.0.100-preview.7.1063+sha.f5acc965e-azdo.5006556.
        Workload installation failed: The JSON value could not be converted to Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadPackId. Path: $.Id | LineNumber: 0 | BytePositionInLine: 39.

        If I delete the ..\sdk\6.0.100-preview.6.21355.2 folder I get it further down:
        Installing workload manifest microsoft.net.sdk.tvos version 15.0.100-preview.7231.
        Garbage collecting for SDK feature bands 6.0.100…
        Workload installation failed: The JSON value could not be converted to Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadPackId. Path: $.Id | LineNumber: 0 | BytePositionInLine: 43.

        If I try to remove anything from the ..\sdk-manifests\6.0.100 folder I get more errors.

      • Luis Linares

        I removed visual studio 2022 and all NET 6 components. I proceed to reinstall everything but i got a similar error:

        Workload installation failed: The JSON value could not be converted to Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadPackId. Path: $.Id | LineNumber: 0 | BytePositionInLine: 39.

        • Gerald VersluisMicrosoft employee

          What worked for me is to remove everything under C:\Program Files\dotnet\metadata\workloads and then run maui-check or dotnet workload install maui manually

          • Damian Wyka

            I did that and workload install finally worked but workload doesnt appear when creating new project…. I did maui-check then dotnet workload install maui everything green but cant create new maui projects

            Edit made clean reinstall of vs and this time it worked. Unfortunetly the bug with debugging is too annoying to play around… Heres hoping rc1 will be finally fully useable on windows

          • Luis Linares

            Thanks for the advice! It worked for me too.

            What worked for me was:

            1.- Remove everything under

            C:\Program Files\dotnet\metadata\workloads

            2.- Run the command

            dotnet workload install maui

            3.- Run the command

            maui-check

            I created a project and everything worked good. I tested Android app and it looks wonderful!

            Unfortunately i can’t test the windows project 🙁

            Cannot start debugging. The startup project cannot be started. Make sure the correct project is set as the startup project. To change the startup project, you must select the command “Set as startup project” from the context menu of Solution Explorer.

            Also, make sure that the debugging settings are correctly configured in the project properties.

            The project is correctly marked as the Startup project but i’m not sure if i need to configure something else.

            Any advices?

            Thanks a lot!

          • Paul Sorauer

            @Luis Linares – David address your issue toward the bottom of the article:

            “At the time of release, we are troubleshooting the latest Windows App SDK Single-project MSIX extension for Visual Studio 2022 and .NET MAUI to address a failure to debug. You can successfully deploy the Windows app directly and run it from the Start menu.”

            Install the MSIX manually – then choose deploy on the windos.ui project and it’ll install to your start menu. From there you can run it and presumably attach the debugger.

    • Alexander Chukanov

      the same error, nothing helps. It is time to use Darts!
      Error: Error resolving type specified in JSON ‘DotNetCheck.Manifest.NuGetFeedVariableMapper, MauiCheck’. Path
      ‘check.variableMappers[0].$type’, line 9, position 74.

        • Douglas Husemann

          After doing the tool uninstall I get this when I try to reinstall maui check

          ❯ dotnet tool install -g Redth.Net.Maui.Check
          C:\Users\drhen\AppData\Local\Temp\grhhwwu0.qsp\restore.csproj(5,3): warning MSB4242: The SDK resolver “Microsoft.DotNet.MSBuildWorkloadSdkResolver” failed to run. Workload pack ‘Microsoft.NET.Runtime.Emscripten.Node’ in manifest ‘microsoft.net.workload.mono.toolchain’ [C:\Program Files\dotnet\sdk-manifests\6.0.100\microsoft.net.workload.mono.toolchain\WorkloadManifest.json] conflicts with manifest ‘microsoft.net.workload.emscripten’ [C:\Program Files\dotnet\sdk-manifests\6.0.100\microsoft.net.workload.emscripten\WorkloadManifest.json]
          C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props(14,3): warning MSB4242: The SDK resolver “Microsoft.DotNet.MSBuildWorkloadSdkResolver” failed to run. Workload pack ‘Microsoft.NET.Runtime.Emscripten.Node’ in manifest ‘microsoft.net.workload.mono.toolchain’ [C:\Program Files\dotnet\sdk-manifests\6.0.100\microsoft.net.workload.mono.toolchain\WorkloadManifest.json] conflicts with manifest ‘microsoft.net.workload.emscripten’ [C:\Program Files\dotnet\sdk-manifests\6.0.100\microsoft.net.workload.emscripten\WorkloadManifest.json]
          C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4236: The SDK ‘Microsoft.NET.SDK.WorkloadAutoImportPropsLocator’ specified could not be found. [C:\Users\drhen\AppData\Local\Temp\grhhwwu0.qsp\restore.csproj]
          The tool package could not be restored.
          Tool ‘redth.net.maui.check’ failed to install. This failure may have been caused by:

          • You are attempting to install a preview release and did not use the –version option to specify the version.
          • A package by this name was found, but it was not a .NET tool.
          • The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
          • You mistyped the name of the tool.

          For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

  • Diego Menezes

    Hi @David, i wanted kow about the property MinimumHeightRequest what was its in Xamarin.Forms, the problem is what this property was bad interpreted for devs,
    I thought that was property set one value minimum for heigth view case you heigth was smaller the value, but no is that. In MAUI this can exist?

        • zenxp

          I do agree. And generally I’m sure that Microsoft will be able to find out the answer in case it feels like it needs to. However since .NET is “Free. Cross platform. Open source.” and also “Supported on Linux, Windows, and macOS” and MAUI is .NET, avoiding Linux support brings some dissonance. I was given tools (C#/F#, .NET), but I can’t use them. Not to mention that most popular cross platform UI frameworks do support Linux. So question arises.

        • Erik

          Linux support is essential for teaching .NET MAUI and its adoption because many Software Engineering students and education institutions use Linux. Therefore, they usually prefer the technology available on all platforms.

      • Ziaul Hasan Hamim

        I think the main competitor of Maui is flutter which supports Linux at a large stage. so I think support for Linux is crucial. Also, there should be extensions(hot reload and other stuff) to develop Maui from vs code properly.

        • Francis Lavoie

          The maui team should capitalize on the success of vs code and give proper support. Maui aim to be a great multi OS framework, like vs code is a great multi OS editor/ide. Only having first class experience on Windows is detrimental.

          Plus, on the Mac, Visual Studio isn’t really usable. Its getting better, but still it requires more love ($+dev).

          It’s the reason vs code is my editor of choice. Either I work on Windows, Mac (main) or Linux. It always work great.

  • Mike Zachael

    When do you expect the debug issue to be fixed?

    Is the error that I should be seeing when trying to debug: “The startup project cannot be launched. Ensure that the correct project is set as the startup project. The startup project can be changed by selecting the ‘Set as Startup Project’ command from the right click menu in Solution Explorer.”