{"id":42407,"date":"2022-09-20T11:03:44","date_gmt":"2022-09-20T18:03:44","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=42407"},"modified":"2022-09-26T11:23:10","modified_gmt":"2022-09-26T18:23:10","slug":"dotnet-maui-in-dotnet-7-rc1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/dotnet-maui-in-dotnet-7-rc1\/","title":{"rendered":".NET MAUI in .NET 7 Release Candidate 1"},"content":{"rendered":"<p>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.<\/p>\n<p>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.<\/p>\n<blockquote><p><strong>Note about Xcode 14<\/strong> 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 <a href=\"https:\/\/github.com\/xamarin\/xamarin-macios\/issues\/15954\">guidance on GitHub<\/a>. These SDKs will also come to Visual Studio, .NET 6, and .NET 7 in service releases soon.<\/p><\/blockquote>\n<h2>Get Started with .NET MAUI in .NET 7<\/h2>\n<p>To quickly get started with RC1, <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">download and install Visual Studio 17.4 Preview 2.1<\/a> 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&#8217;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.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/09\/framework-selector.png\" alt=\"framework selector\" \/><\/p>\n<p>From the command line you can now see version details about all of your workload dependencies by running <code>dotnet workload list<\/code>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/09\/workload-list.png\" alt=\"workload list report\" \/><\/p>\n<blockquote><p><strong>Upgrading projects from .NET 6<\/strong> &#8211; in many cases after installing .NET 7 you only need to update <code>net6.0<\/code> references in the <em>csproj<\/em> file to <code>net7.0<\/code>. 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.<\/p><\/blockquote>\n<h2>Maps<\/h2>\n<p>.NET MAUI now ships with a <code>Map<\/code> control that you can add to your project with the <code>Microsoft.Maui.Controls.Maps<\/code> 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.<\/p>\n<p>To initialize the control, add <code>.UseMauiMaps()<\/code> in your <code>MauiProgram<\/code> builder and then add the <code>Map<\/code> control to your view.<\/p>\n<pre><code class=\"language-xaml\">&lt;Grid&gt;\r\n    &lt;Map x:Name=\"map\"\/&gt;\r\n&lt;\/Grid&gt;<\/code><\/pre>\n<pre><code class=\"language-csharp\">protected override void OnNavigatedTo(NavigatedToEventArgs args)\r\n{\r\n    base.OnNavigatedTo(args);\r\n\r\n    var hanaLoc = new Location(20.7557, -155.9880);\r\n\r\n    MapSpan mapSpan = MapSpan.FromCenterAndRadius(hanaLoc, Distance.FromKilometers(3));\r\n    map.MoveToRegion(mapSpan);\r\n    map.Pins.Add(new Pin\r\n    {\r\n        Label = \"Welcome to .NET MAUI!\",\r\n        Location = hanaLoc,\r\n    });\r\n}<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/09\/maps.png\" alt=\"map control on mac, android, and ios\" \/><\/p>\n<p>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 <code>WebView<\/code> implementation and <a href=\"https:\/\/github.com\/CommunityToolkit\/Maui\/issues\/605\">opened a proposal<\/a> on the .NET MAUI Community Toolkit.<\/p>\n<h2>Desktop Improvements<\/h2>\n<p>We have seen many of you using .NET MAUI to target desktop platforms, and we&#8217;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.<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/09\/Figure8.png\" alt=\"context menu on Windows, .NET MAUI in .NET 7 Release Candidate 1\" width=\"597\" height=\"569\" \/><\/p>\n<h3>Context Menu<\/h3>\n<p>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.<\/p>\n<pre><code class=\"language-xaml\">&lt;Editor Text=\"This is my text and I want bold.\"&gt;\r\n    &lt;FlyoutBase.ContextFlyout&gt;\r\n        &lt;MenuFlyout&gt;\r\n            &lt;MenuFlyoutItem Text=\"Bold\" Clicked=\"OnBoldClicked\"\/&gt;\r\n            &lt;MenuFlyoutItem Text=\"Italics\" Clicked=\"OnItalicsClicked\"\/&gt;\r\n            &lt;MenuFlyoutItem Text=\"Underline\" Clicked=\"OnUnderlineClicked\"\/&gt;\r\n        &lt;\/MenuFlyout&gt;\r\n    &lt;\/FlyoutBase.ContextFlyout&gt;\r\n&lt;\/Editor&gt;<\/code><\/pre>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/09\/maui-tooltip.png\" alt=\"tooltip, .NET MAUI in .NET 7 Release Candidate 1\" width=\"868\" height=\"460\" \/><\/p>\n<h3>Tooltips<\/h3>\n<p>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.<\/p>\n<pre><code class=\"language-xaml\">&lt;RadioButton Value=\"home\" \r\n    ToolTipProperties.Text=\"Home\"\r\n    SemanticProperties.DescriptionText=\"Home menu item\"&gt;\r\n    &lt;RadioButton.Content&gt;\r\n        &lt;Image Source=\"home.png\"\/&gt;\r\n    &lt;\/RadioButton.Content&gt;\r\n&lt;\/RadioButton&gt;<\/code><\/pre>\n<h3>Gestures<\/h3>\n<p>Desktop apps need a few gestures that aren\u2019t 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.<\/p>\n<pre><code class=\"language-xaml\">&lt;PointerGestureRecognizer PointerEntered=\"HoverBegan\" PointerExited=\"HoverEnded\" PointerMoved=\"HoverMoved\" \/&gt;<\/code><\/pre>\n<pre><code class=\"language-csharp\">var secondaryClick = new TapGestureRecognizer()\r\n{\r\n    Buttons = ButtonsMask.Secondary\r\n};\r\n\r\nsecondaryClick.Tapped += SecondaryClick_Tapped;<\/code><\/pre>\n<h3>Window Size and Position<\/h3>\n<p>We&#8217;ve added properties and events to the Window so you have control at the cross-platform layer rather than writing platform code. These include:<\/p>\n<ul>\n<li>X\/Y position*<\/li>\n<li>Width\/Height*<\/li>\n<li>Minimum Width\/Height<\/li>\n<li>Maximum Width\/Height<\/li>\n<li>SizeChanged<\/li>\n<\/ul>\n<p><i>* not supported on macOS<\/i><\/p>\n<p>Now to size and center your window on the current display you can do this:<\/p>\n<pre><code class=\"language-csharp\">const int newWidth = 800;\r\nconst int newHeight = 600;\r\n\r\n\/\/ get screen size\r\nvar disp = DeviceDisplay.Current.MainDisplayInfo;\r\n\r\n\/\/ center the window\r\nWindow.X = (disp.Width \/ disp.Density - newWidth) \/ 2;\r\nWindow.Y = (disp.Height \/ disp.Density - newHeight) \/ 2;\r\n\r\n\/\/ resize\r\nWindow.Width = newWidth;\r\nWindow.Height = newHeight;<\/code><\/pre>\n<h2>We need your feedback<\/h2>\n<p>We\u2019d love to hear from you! As you encounter any issues, please file a report on GitHub at <a href=\"https:\/\/github.com\/dotnet\/maui\/issues\/new\/choose\">dotnet\/maui<\/a>. For any issues related to Visual Studio 2022, please use the <a href=\"https:\/\/learn.microsoft.com\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio?view=vs-2022\">Report a Problem<\/a> button.<\/p>\n<h2>Resources<\/h2>\n<p>Install and Getting Started:<\/p>\n<ul>\n<li><a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">Visual Studio 17.4 Preview 2.1<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/dotnet\/maui-samples\">.NET MAUI Samples<\/a><\/li>\n<\/ul>\n<p>Release notes:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/dotnet\/maui\/releases\/tag\/7.0.0-rc.1.6683\">.NET MAUI<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/xamarin\/xamarin-android\/releases\">.NET for Android<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/xamarin\/xamarin-macios\/releases\/tag\/untagged-e43f0fe4c3cf3ff33a50\">.NET for iOS and macOS<\/a><\/li>\n<\/ul>\n<p>Known issues:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/xamarin\/xamarin-android\/wiki\/Known-issues-in-.NET\">.NET for Android<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/xamarin\/xamarin-macios\/wiki\/Known-issues-in-.NET7\">.NET for iOS and macOS<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>.NET MAUI is now part of .NET 7 in RC1 with tons of improvements, and a few new features.<\/p>\n","protected":false},"author":553,"featured_media":42408,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,7233],"tags":[7611,7238],"class_list":["post-42407","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-maui","tag-dotnet-7","tag-net-maui"],"acf":[],"blog_post_summary":"<p>.NET MAUI is now part of .NET 7 in RC1 with tons of improvements, and a few new features.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/42407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/553"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=42407"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/42407\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/42408"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=42407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=42407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=42407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}