How to add a feature layer from a map package

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 local feature service layer to the map using the ArcGISLocalFeatureLayer 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 location 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. Identify the layer name of the layer from within the map package that you want to display in the map. Alternatively, if you don't know the name of the layer used in the map package, you can use the LayerID.

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

Compile and run your application.

1/27/2015