.NET MAUI in .NET 7 Release Candidate 1

David Ortinau

Today we are excited to announce the availability of .NET Multi-platform App UI (MAUI) in .NET 7 release candidate 1 (RC1) with the release of Visual Studio 17.4 Preview 2.1. This includes the foundational SDKs .NET for Android, iOS, Mac Catalyst, and macOS. With the Tizen workload installed, the same code also runs on numerous Samsung devices including phones, televisions, appliances, and wearables.

Our top priority for this release of .NET MAUI is increasing the overall quality and reliability of the toolkit. .NET 7 RC1 includes the highest priority quality fixes based on your GitHub feedback. Maps and DualScreen join .NET MAUI in .NET 7 to fill two gaps for mobile developers upgrading from Xamarin. We have also added some fundamental desktop features for tooltips, right-click, hover, window size, and context menus.

Note about Xcode 14 for iOS, iPadOS, and macOS: .NET 7 is currently compatible with Xcode 13 and the related SDK versions. To get Xcode 14 support today for Xamarin SDKs, follow our guidance on GitHub. These SDKs will also come to Visual Studio, .NET 6, and .NET 7 in service releases soon.

Get Started with .NET MAUI in .NET 7

To quickly get started with RC1, download and install Visual Studio 17.4 Preview 2.1 on Windows or Mac. While on Windows you can install Visual Studio versions side by side, this is not the same for Mac and for installing .NET. To address this, we have worked hard in .NET 7 to ensure you can continue building .NET 6 projects even after installing .NET 7. In fact, in the new project dialog, you’ll notice that .NET 6 and .NET 7 will both be presented for you to choose from when creating a new .NET MAUI project. You can adopt .NET MAUI versions at your own cadence.

framework selector

From the command line you can now see version details about all of your workload dependencies by running dotnet workload list.

workload list report

Upgrading projects from .NET 6 – in many cases after installing .NET 7 you only need to update net6.0 references in the csproj file to net7.0. We recommend closing the solution, deleting your bin and obj folders, and reopening the project to now restore .NET 7 dependencies from a clean starting point.

Maps

.NET MAUI now ships with a Map control that you can add to your project with the Microsoft.Maui.Controls.Maps NuGet package. This control is ideal for displaying and annotating maps using the native maps from each mobile platform. You can draw shapes on the map, drop pins, add custom pins, and even geocode street addresses, latitude, and longitude. To use the map control, add the NuGet package and initialize the control in your MauiProgram.

To initialize the control, add .UseMauiMaps() in your MauiProgram builder and then add the Map control to your view.

<Grid>
    <Map x:Name="map"/>
</Grid>
protected override void OnNavigatedTo(NavigatedToEventArgs args)
{
    base.OnNavigatedTo(args);

    var hanaLoc = new Location(20.7557, -155.9880);

    MapSpan mapSpan = MapSpan.FromCenterAndRadius(hanaLoc, Distance.FromKilometers(3));
    map.MoveToRegion(mapSpan);
    map.Pins.Add(new Pin
    {
        Label = "Welcome to .NET MAUI!",
        Location = hanaLoc,
    });
}

map control on mac, android, and ios

As you can see in this image, the control also works on macOS. WinUI 3 does not currently have a native map control. To fill that gap, we have created a WebView implementation and opened a proposal on the .NET MAUI Community Toolkit.

Desktop Improvements

We have seen many of you using .NET MAUI to target desktop platforms, and we’ve been working closely with quite a few customers who are also building cross-platform desktop applications with .NET MAUI. In response to your needs and feedback, we have surfaced a few useful features targeted at creating better desktop experiences including context menus, tooltips, pointer gestures, right-click mapping on tap gestures, and more control over the window size. Below are some highlights for you to explore in RC1.

context menu on Windows, .NET MAUI in .NET 7 Release Candidate 1

Context Menu

You can now attach a context menu to any visual element using a MenuFlyout control. When the user right-clicks that view, the flyout will appear in that location when run on a desktop platform.

<Editor Text="This is my text and I want bold.">
    <FlyoutBase.ContextFlyout>
        <MenuFlyout>
            <MenuFlyoutItem Text="Bold" Clicked="OnBoldClicked"/>
            <MenuFlyoutItem Text="Italics" Clicked="OnItalicsClicked"/>
            <MenuFlyoutItem Text="Underline" Clicked="OnUnderlineClicked"/>
        </MenuFlyout>
    </FlyoutBase.ContextFlyout>
</Editor>

tooltip, .NET MAUI in .NET 7 Release Candidate 1

Tooltips

Sometimes you want to provide details about what an element is onscreen when the user hovers the cursor over it. We have added a simple attached property for you to set that text, and the display and disappearance of the tooltip with automatically be triggered. This is the same pattern used for adding accessibility descriptions via semantic properties.

<RadioButton Value="home" 
    ToolTipProperties.Text="Home"
    SemanticProperties.DescriptionText="Home menu item">
    <RadioButton.Content>
        <Image Source="home.png"/>
    </RadioButton.Content>
</RadioButton>

Gestures

Desktop apps need a few gestures that aren’t used on mobile, so in .NET 7 we are adding a pointer gesture for handling hover events and a button mask for secondary (commonly right-click) taps.

<PointerGestureRecognizer PointerEntered="HoverBegan" PointerExited="HoverEnded" PointerMoved="HoverMoved" />
var secondaryClick = new TapGestureRecognizer()
{
    Buttons = ButtonsMask.Secondary
};

secondaryClick.Tapped += SecondaryClick_Tapped;

Window Size and Position

We’ve added properties and events to the Window so you have control at the cross-platform layer rather than writing platform code. These include:

  • X/Y position*
  • Width/Height*
  • Minimum Width/Height
  • Maximum Width/Height
  • SizeChanged

* not supported on macOS

Now to size and center your window on the current display you can do this:

const int newWidth = 800;
const int newHeight = 600;

// get screen size
var disp = DeviceDisplay.Current.MainDisplayInfo;

// center the window
Window.X = (disp.Width / disp.Density - newWidth) / 2;
Window.Y = (disp.Height / disp.Density - newHeight) / 2;

// resize
Window.Width = newWidth;
Window.Height = newHeight;

We need your feedback

We’d love to hear from you! As you encounter any issues, please file a report on GitHub at dotnet/maui. For any issues related to Visual Studio 2022, please use the Report a Problem button.

Resources

Install and Getting Started:

Release notes:

Known issues:

32 comments

Discussion is closed. Login to edit/delete existing comments.

  • Alessandro Caliaro 2

    Excellent David.
    Can context menu work also on mobile with a long tap?

    • Michael Bond 2

      I’d like to know this as well – especially since iPad users can have a trackpad or other external pointing device.

  • Michael Bond 4

    Any idea what this error could be? This is after updating to VS2022 17.4 Preview 2.1, and creating a new MAUI app and trying to clean / build it.

    Error  NU1012  Platform version is not present for one or more target frameworks, even though they have specified a platform: net7.0-ios, net7.0-maccatalyst
    • Connor Galligan 2

      Same here. Using dotnet restore doesn’t seem to fix it either.

      • Herrick, Andrew 3

        same here… anyone have a workaround solution?

        • David OrtinauMicrosoft employee 0

          For the immediate, removing those target frameworks from your csproj should get you building again. We are currently building and validating a fix that will be published asap.

  • William Fry 1

    Are you teasing me with a right-click menu for “Bold”, “Italic” and “Underline”? I’ve been really hoping for a Rich-Edit TextBlock control so I can improve the readability of help messages. While bulleted and numbered lists would be nice, I’d be thrilled to start with the basics of Bold/Italic!

    • William Fry 0

      I apologize for being new to this. I just discovered that Label has a FormattedText property! That’s awesome!

  • 明 黄 1

    Regarding the release of 17.4 preview 2.1, MAUI 6.0 also lost the Template, how can I solve it?

    • David OrtinauMicrosoft employee 0

      When creating a new project you should be able to select .NET 6 in the dialog. If it’s not present and working, please report a problem in Visual Studio.

  • Ryan SOUTH 0

    Is there going to be overlapping support/releases for .net 6 and .net 7 like there is going to be for .net 7 and .net 8?

  • Marcelo Oliveira Santos 1

    I Just need MediaElement.

  • Eric Hamrick 0

    On Mac M1. I get an error installing with Mac installer so when I do a : “sudo dotnet workload install maui” I receive an error below when I reach this point in the workload install. Is there another nuget feed I should be using?

    Installing pack Microsoft.Maui.Sdk version 7.0.0-rc.2.6731…
    Writing workload pack installation record for Microsoft.Maui.Sdk.net7 version 7.0.0-rc.2.6731…
    Installing pack Microsoft.Maui.Sdk version 6.0.533…
    ..
    ..
    Workload installation failed: microsoft.maui.sdk::6.0.533 is not found in NuGet feeds https://api.nuget.org/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json“.

  • Jeremy Powell 0

    Great to see the progress on desktop support! Really hope we get keyboard accelerators in menus soon, it’s really a must-have for accessibility.

    • David OrtinauMicrosoft employee 0

      Agreed! One of our teammates was working on a project for that this week during our hackathon.

  • LiFei 2

    The inability to compile EXE’s MAUI on the desktop is a pity, as it is not applicable to the needs of most enterprises

  • tonrin17 6

    I was very excited about MAUI first release, but after creating a first sample application I hit a huge wall that blocks efficient development.

    1. Why there is no MAUI XAML preview in Visual Studio? How can we see progress in creating design for views? Live preview is not enough – if a new view is not connected yet with other UI elements, there is no way to see result of your current code. Also if the view is hidden inside multiple levels of another views it is time-consuming to get there every application restart.

    2. Hot Reload function is more like “Random Reload” since many changes in XAML code are not reflected correctly while running application. You see something in running app, change the XAML code and you think if your code is wrong or MAUI is bugged and after application restart you see that the changes were just applied incorrectly by Hot Reload…

    3. Debugger faced an error, please select a new debugger to be attached or close the application – similiar message is visible many times after nesting multiple layouts in other layouts.

    According to the above I was unable to finish the sample application.

    Hope we will see fixes and really huge improvements in next releases for .NET 7 or 8.
    Idea for the MAUI seems nice but still much work is required to be able to use it.

    • Jan SeriÅ¡ 2

      MAUI visual designer has been scrapped and is not going to come. They don’t have capacities and don’t plan extending.

Feedback usabilla icon