Announcing Preview 1 of .NET MAUI support with ArcGIS Runtime SDK for .NET

4756
5
04-06-2022 08:49 AM
Labels (1)
MichaelBranscomb
Esri Frequent Contributor
2 5 4,756

Preview 1 of support for the .NET Multi-platform App UI (MAUI) framework with ArcGIS Runtime SDK for .NET is now available. The evolution of Xamarin.Forms, .NET MAUI is a cross-platform framework for creating native mobile and desktop apps with C# and XAML, and enables you to develop apps that can run on Android, iOS, and Windows from a single shared code-base.

 

Get started with .NET MAUI and ArcGIS Runtime SDK for .NET

 

Prerequisites

Visual Studio 2022 Preview (Version 17.2 or higher)

Note: Esri.ArcGISRuntime.Maui version 100.13.1-preview1 supports .NET MAUI Preview 14 only. Support for the recent .NET MAUI RC 1 release will be available in a future preview of Esri.ArcGISRuntime.Maui.

 

Steps

Note:- For more information about steps 1.-4. see the .NET MAUI topic Build your first app in the Microsoft documentation.


1. Launch Visual Studio 2022 17.2 Preview, and in the start window click Create a new project to create a new project.

2. In the Create a new project window, select MAUI in the Project type drop-down, select the .NET MAUI App (Preview) template, and click the Next button.

3. In the Configure your new project window, name your project, choose a suitable location for it, and click the Create button.

4. Wait for the project to be created, and its dependencies to be restored.

5. In Solution Explorer window right click the project and choose `Edit Project File`

6. Modify the TargetFrameworks to remove net6.0-maccatalyst:

 

<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>

 

Note: There are no plans to support MacCatalyst at this time.

7. Add references to Esri.ArcGISRuntime.Maui Preview 1 and Esri.ArcGISRuntime.WinUI and global using statements:

 

<ItemGroup>
    <PackageReference Include="Esri.ArcGISRuntime.Maui" Version="100.13.1-preview1" />
    <PackageReference Include="Esri.ArcGISRuntime.WinUI" Version="100.13.1" Condition="$(TargetFramework.Contains('-windows'))" />
    <Using Include="Esri.ArcGISRuntime.Maui" />
    <Using Include="Esri.ArcGISRuntime.Mapping" />
</ItemGroup>​

 

8. Set the Windows TargetPlatformMinVersion and SupportedOSPlatformVersion to version 10.0.18362.0:

 

<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</TargetPlatformMinVersion>

 

9. Set the Android SupportedOSPlatformVersion to version 23:

 

<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">23.0</SupportedOSPlatformVersion>

 

10. Open MauiProgram.cs and add .UseArcGISRuntime() to the builder:

 

var builder = MauiApp.CreateBuilder();
builder
    .UseMauiApp<App>()
    .ConfigureFonts(fonts =>
    {
        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
    }).UseArcGISRuntime();

 

11. Open MainPage.xaml

12. Add an esri namespace declaration:

 

xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"

 

13. Add a map view:

 

<esri:MapView x:Name="mapView"/>

 

15. Open MainPage.xaml.cs
16. Create a Map with a Basemap and assign to the MapView:

 

mapView.Map = new Esri.ArcGISRuntime.Mapping.Map(new Basemap(BasemapStyle.ArcGISNova)
{
    ApiKey = "<Your ArcGIS Developer API Key here>"
});

 

Note:- If you don't already have an ArcGIS Developer account and an API key for using ArcGIS Platform location services go to https://developers.arcgis.com/sign-up/ for more information.

17. Now it's time to build and run your app. Below is an example from following the steps above and running on a Windows Machine.

MAUI.png

 

Known Issues

  • Esri.ArcGISRuntime.Maui version 100.13.1-preview1 supports .NET MAUI Preview 14 only. Support for the recent .NET MAUI RC 1 release will be available in a future preview of Esri.ArcGISRuntime.Maui.
  • The need to add an explicit package reference to Esri.ArcGISRuntime.WinUI will be resolved in a future release.

 

Feedback

If you have any feedback on this preview or find any bugs please let us know via the ArcGIS Runtime SDK for .NET questions board 

 

Additional Resources

5 Comments