ArcGIS Runtime SDK for .NET

Add ArcGIS Runtime SDK references

To work with ArcGIS Runtime SDK for .NET in your Visual Studio (Windows or Mac) project, you need to add the appropriate ArcGIS Runtime API NuGet package and also add any required XML namespace references in your XAML. This process is not unique to ArcGIS Runtime SDK for .NET, you may follow a similar workflow for other APIs you want to use in your project.

The following steps guide you through creating a new Visual Studio project for your Universal Windows app. You will also learn how to add the proper references for working with ArcGIS Runtime SDK for .NET classes. You can follow these same basic steps for every ArcGIS Runtime SDK for .NET project you create.

Tip:

ArcGIS Runtime SDK for .NET Visual Studio Extension provides a project template (for use in Visual Studio on Windows only) for creating your mapping app, called ArcGIS Runtime App. See the Install the SDK topic for information about installing the ArcGIS Runtime SDK for .NET Visual Studio Extension.

Create a Universal Windows app

Use Visual Studio to create a Universal Windows app.

  1. Open a supported version of Microsoft Visual Studio.
  2. Choose File > New > Project (or click New Project on the Start page) to create a project.
  3. Click Windows > Universal > Blank App in the New Project dialog box template list.
    Tip:

    If you create your app using the ArcGIS Runtime App template, you do not need to complete the rest of the steps described in this topic. Creating your project from the template adds the appropriate NuGet packages and references as well as a page with a map view containing a single base layer.

  4. Choose a folder location for your new project and give it a name.
  5. Click OK to create the project.

    Your solution opens in Visual Studio and contains a page called MainPage.xaml.

  6. Next, you'll add the appropriate ArcGIS Runtime SDK for .NET NuGet package for this platform.

Add ArcGIS Runtime SDK NuGet packages

ArcGIS Runtime SDK NuGet packages are hosted on NuGet.org. If you have an internet connection, you can access these packages and add them to your Visual Studio (Windows or Mac) project without having to install anything locally. If you've installed the ArcGIS Runtime SDK for .NET Visual Studio Extension (Windows only), then you also have these packages available in a local NuGet package source (called Esri).

  1. Open the NuGet Package Manager (Project > Manage NuGet Packages, for example).
  2. Choose the Browse tab in the manager. Choose the Esri package source to add locally installed packages. Otherwise, choose the online nuget.org package source. NuGet hosts around 100,000 packages, so you'll need to use the Search text box to locate the ArcGIS Runtime packages if using the online package source.
  3. To locate the ArcGIS Runtime packages, type ArcGIS Runtime in the Search text box. You will see several matches (for various versions and platforms).
    ArcGIS Runtime NuGet packages
  4. Select a version 100.4.0 package for your platform. Click Install to add the package to your project.
  5. Choose OK to proceed with the installation and then I Accept to accept the license agreement.

After adding the package, you'll be able to work with the components in ArcGIS Runtime for .NET API in your code.

Add XML namespace references

In addition to the project reference you made to the ArcGIS Runtime assembly, you must also add an XML namespace reference in your XAML page in order to add the MapView control to your page.

  1. Open the MainPage.xaml file in the Visual Studio designer.
  2. Go to the XAML view of the designer and add the following XML namespace reference to the PageContentPage XAML element. Visual Studio offers Intellisense to help complete the URL portion of the statement.
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls"
  3. The Esri.ArcGISRuntime.UI.Controls namespace contains the MapView and SceneView controls for displaying a map or scene on your page. Using the MVVM pattern, you can bind a Map in your code to the control.
  4. You can now use the XML prefix you've defined to work with ArcGIS Runtime SDK in your XAML. The following code sample defines a new MapView control.
    <esriUI:MapView x:Name="MyMapView" Map="{x:Bind ViewModel.Map, Mode=OneWay}" />

    You can display a map in your app by ...

    • Defining it entirely with XAML (you may need to add more XML namespace references for things like Map and layers)
    • Use data binding to associate the MapView control defined in XAML to a Map in another class (a ViewModel using the MVVM pattern, for example)
    • Define the MapView in your XAML and assign a map in your code behind, as shown in the following example.
    // create a new Map with a streets basemap
    var map = new Map(Basemap.CreateStreets());
    // assign the map to MyMapView (MapView control)
    MyMapView.Map = map;

The process described in this topic is generally the first thing you'll do for each ArcGIS Runtime SDK for .NET project you create from a standard Visual Studio template. The details for adding these references differ slightly between SDK platforms.

Related topics