
When adding a Map control to your Silverlight application, your code will always contain two parts:
The following example shows the XAML markup in a simple Silverlight application that includes an ArcGIS Silverlight API Map control which contains a single ArcGIS Server tiled map service layer. In addition, a custom startup extent has been added to the map control to define the the initial map extent when the application starts.
The remainder of this document will walk you through the steps to include this XAML in your Silverlight application.
<UserControl x:Class="SilverlightApp.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client">
<Grid x:Name="LayoutRoot" Background="White">
<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>
</Grid>
</UserControl>
The following steps assume you have created a Silverlight application in Visual Studio and are working in the XAML view of the main page (e.g. Page.xaml) of your application.
<UserControl x:Class="SilverlightApp.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client">
<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="MyMap" >
</esri:Map>
</Grid>
<esri:Map x:Name="MyMap" >
<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>
<esri:Map x:Name="MyMap" Extent="-120, 20, -100, 40" >
By default, the first layer with a valid spatial reference defines the spatial reference for the map. Dynamic ArcGIS Server map and image services as well as feature layers (FeatureLayer) will be reprojected to the map's spatial reference, if necessary. Tiled map services layers will not be reprojected - the spatial reference of the layer and map must match for the layer to display in the map. To define an explicit spatial reference for the map, create an Envelope and assign a SpatialReference. Use the following XAML as a guide:
<esri:Map x:Name="MyMap">
<esri:Map.Extent>
<esriGeometry:Envelope XMin="661140" YMin="-1420246" XMax="3015668" YMax="1594451" >
<esriGeometry:Envelope.SpatialReference>
<esriGeometry:SpatialReference WKID="26777"/>
</esriGeometry:Envelope.SpatialReference>
</esriGeometry:Envelope>
</esri:Map.Extent>
. . .