Getting started
Creating an application using the ArcGIS API for Silverlight
To begin working with the ArcGIS API for Silverlight, follow these steps:
- Install prerequisites, then download and install the ArcGIS API for Silverlight. See Installation for details.
- In Visual Studio 2010, create a Silverlight application project and
with a host website. Note:
If you are creating a new Silverlight application, in the New Silverlight Application dialog box, choose Host the Silverlight application in a new website with and a New Web project type setting of ASP.NET Web Application Project.
Tip:To get started in Expression Blend 4, see Getting started in Expresion Blend
- Add a reference to one or more of the ArcGIS API for Silverlight
assemblies in your Silverlight application project by taking the following steps:
- In Visual Studio 2010, open Solution Explorer and locate the Silverlight application project.
- Right-click the References node and click Add Reference.
- Under the .NET tab, select and add the ESRI.ArcGIS.Client assembly.
- In your Silverlight application, open a Silverlight user
control in XAML view (for example, MainPage.xaml) and add code to access and
display an ArcGIS Server map service.
For example, the following steps and code show the items necessary to add
and display a map and an ArcGIS Server cached map service.
- Add a namespace reference to the ArcGIS Silverlight schema.
- Add a Map control.
- Add an ArcGISTiledMapServerLayer in the Map element.
- On the ArcGISTiledMapServerLayer element, set the Url attribute to the REST endpoint for the ArcGIS Server cached map service.
<UserControl x:Class="SilverlightApplication.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot"> <esri:Map x:Name="MyMap" > <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/> </esri:Map> </Grid> </UserControl>
- Compile the code and run your application. Your Silverlight application should be hosted in an HTML or page on a web server and accessed in a browser. Visual Studio's internal Web Development Server will work. If the map is blank, check the following:
- Accessing an HTML page via the file system does not allow remote map services to display within the Map control. By default, files accessed via the file system in a browser have restricted access to remote services which include ArcGIS Online services.
- To access an ArcGIS Server site on a different domain than the Silverlight application host site, the ArcGIS Server site must enable remote access to services. This is accomplished using clientaccesspolicy.xml or crossdomain.xml. In most cases, just place the XML file at the root of your website (for example, for IIS, C:\inetpub\wwwroot\).
Note:ArcGIS Online already hosts both files to support cross-domain access for all Silverlight clients. See FAQs for more details.
For more information
See Creating a maps and Adding layers for more information about the components presented in this tutorial.
To explore ArcGIS API for Silverlight components in action, see the Interactive SDK samples.
For tips on discovering ArcGIS Server map services, see ArcGIS Server services.