How to add a graphics layer

If you have not already done so, create a WPF application with a map as described in Creating a map. Your map's Extensible Application Markup Language (XAML) should appear as follows:

<esri:Map x:Name="MyMap" Extent="-120, 20, -100, 40" >
  <esri:Map.Layers>
    <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
      Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
  </esri:Map.Layers>
 </esri:Map>

In the map's XAML element, declare a GraphicsLayer. Be sure to put it below the tiled map service layer.

<esri:Map x:Name="MyMap" Extent="-120, 20, -100, 40" >
  <esri:Map.Layers>
    <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
      Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
    <esri:GraphicsLayer />
  </esri:Map.Layers>
</esri:Map>

When you declare a graphics layer, you must give it an ID. You'll use this ID in your application's .NET code (that is, code-behind) to get a reference to the layer. The following code assigns the GraphicsLayer an ID of "MyGraphicsLayer":

<esri:Map x:Name="MyMap" Extent="-120, 20, -100, 40" >
  <esri:Map.Layers>
    <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
      Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
    <esri:GraphicsLayer ID="MyGraphicsLayer" />
  </esri:Map.Layers>
</esri:Map>
1/27/2015