How to add a feature layer from an online service

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.

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 feature service layer to the map using the FeatureLayer element. Define the Url to the feature service endpoint and include a unique ID for the layer.

<Grid x:Name="LayoutRoot" Background="White">
        <esri:Map x:Name="MyMap" >
            <esri:FeatureLayer ID="Fire Incidents" 
                      Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0" />
        </esri:Map>
    </Grid>

Compile and run your application.

1/27/2015