Getting started

Windows Presentation Foundation (WPF) provides a development environment for building rich Windows user experiences for the desktop. The ArcGIS API for WPF enables you to integrate ArcGIS Server, Esri MapIt, and Bing Maps services and capabilities in a WPF application.

Creating an application using the ArcGIS API for WPF

To begin working with the ArcGIS API for WPF, follow these steps:

Path to getting started with the

This topic takes you through the steps of creating a new ArcGIS API for WPF application using Visual Studio 2010.

NoteNote:

To get started in Expression Blend 4, see Getting started in Expresion Blend.

  1. Install prerequisites, then download and install the ArcGIS API for WPF. See Installation for details.
  2. In Visual Studio 2010, open the New Project dialog box by choosing File > New > Project.
  3. On the New Project dialog box, select Installed Templates, expand the Visual C# node, select Windows, and select the WPF Application template. Verify that the project is set to use the .NET Framework 4 in the drop-down list at the top of the template list. Provide a name and location for your project. Click OK to generate the project and close the New Project dialog box. See the following screen shot:
    Screen shot of the New Project dialog box.
    NoteNote:

    While this topic uses C#, follow the same basic workflow to develop in VB.NET. To follow this topic using VB.NET instead of C#, use the Visual Basic WFP Application template. In the code-behind in the following steps, VB.NET code replaces the C# code shown here.

  4. Add a reference to one or more of the ArcGIS API for WPF assemblies into your WPF application project by taking the following steps:
    1. Open the Solution Explorer and expand the WPF application project.
    2. Right-click the References node and click Add Reference from the context menu. See the following screen shot:
      Screen shot of the Add Reference context menu.
    3. After you click Add Reference, the Add Reference dialog box appears. Under the .NET tab on the Add Reference dialog box, select and add the ESRI.ArcGIS.Client assembly. See the following screen shot:
      Screen shot of the Add Reference dialog box.
      CautionCaution:

      Make sure if you are working in the .NET Framework 4.0, that you have selected the .NET Framework 4.0 version of the assembly. The path to the DLL, as shown on the Add Reference dialog box in the previous screen shot, includes DotNet40. The .NET Framework 3.5 version of the DLL is in the DotNet35 folder.

  5. Open the MainWindow.xaml WPF window. Take the following steps to add a Map control that accesses and displays an ArcGIS Server cached map service:
    1. In the Window element, add a namespace reference to the ArcGIS WPF schema. See the following code:
      <Window x:Class="WPFGettingStartedTopic.MainWindow"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
              Title="MainWindow" Height="350" Width="525">
      
    2. Add a Map control to the Window's Grid as shown in the following code.
      <Grid>
          <esri:Map x:Name="MyMap" >
          </esri:Map>
      </Grid>
      
      TipTip:

      A Map control can also be dragged from the toolbox onto the design surface.

    3. Add an ArcGISTiledMapServerLayer to the Map. Set its Url attribute to the REST endpoint for an ArcGIS Server cached map service. See the following code:
      <Grid>
          <esri:Map x:Name="MyMap" >
              <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"            
      			Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
          </esri:Map>
      </Grid>
      
  6. Compile the code and run your application. Your application will look similar to the following screen shot:Screen shot of the running WPF application.

For more information

See Creating a map and Adding layers for more information about the components presented in this tutorial.

To explore ArcGIS API for WPF components in action, see the Interactive SDK samples.

For tips on discovering ArcGIS Server map services, see ArcGIS Server services.

1/23/2012