How to add a local dynamic map service layer

The following steps assume you have created a Windows Presentation Foundation (WPF) application in Visual Studio and are working in the Extensible Application Markup Language (XAML) view of the main page of your application.

Add a reference to ESRI.ArcGIS.Client.dll and ESRI.ArcGIS.Client.Local.dll.

In XAML, add an Extensible Markup Language (XML) namespace that references the ArcGIS schema for WPF.

xmlns:esri="http://schemas.esri.com/arcgis/client/2009">

Add the Map control element to a container element in the page. In this example, the container is a Grid. Use the ESRI.ArcGIS.Client namespace identifier, esri, to define the namespace that contains the Map control. Give the Map control a unique name using the x:Name attribute.

<Grid x:Name="LayoutRoot" Background="White">
        <esri:Map x:Name="MyMap" >
        </esri:Map>
    </Grid>

Add an ArcGIS for Server dynamic map service layer to the map using the ArcGISLocalDynamicMapServiceLayer element. Include a unique ID for the layer and define the path to the map document. The supported source is an ArcGIS Map Package (.mpk) that can be authored in ArcMap. The following shows the path set to the location of a map package included with the installed software development kit (SDK). You will need to replace this path with that of your own.

<Grid x:Name="LayoutRoot" Background="White">
        <esri:Map x:Name="MyMap" >
            <esri:ArcGISLocalDynamicMapServiceLayer ID="USA" Path="C:\Program Files (x86)\ArcGIS SDKs\WPF10.2.5\sdk\samples
\data\mpks\USCitiesStates.mpk"/>
        </esri:Map>
    </Grid>

Compile and run your application.

NoteNote:
  • The Map's SnapToLevels property determines if the Map control will only be rendered at predefined scale levels. By default, Map.SnapToLevels is false, which allows the Map control to render map tiles between scale levels. If true, tile information from the first ArcGISTiledMapServiceLayer in the Map's layer collection is used to define scale levels.
  • The background color for an ArcGISDynamicMapServiceLayer will always be transparent.
  • Use the Opacity property to define variable transparency for a layer. Layer opacity is applied on the client using the WPF platform capabilities.
1/27/2015