Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to create a simple webgis with silverlight. Software that I used to make the application: ArcGIS Desktop 10 (without sp), ArcGIS Server 10, Silverlight 4, Microsoft blend 4, and Visual Studio 2010 sp1. We generally use the code below to add layers to map:

<esri:Map x:Name="Map" >
              <esri:ArcGISDynamicMapServiceLayer ID="samplewebgis" 
                    Url="http://m-pc/arcgis/rest/services/test/MapServer" />        

But when i use the code, the map legend shows no layers. then I tried the code below:

<esri:Map x:Name="Map"   Grid.RowSpan="3">                                  

      <esri:FeatureLayer  ID="xx" Url="http://m-pc/arcgis/rest/services/test/MapServer/0"/> 
      <esri:FeatureLayer  ID="yy" Url="http://m-pc/arcgis/rest/services/test/MapServer/1" /> 


This code works properly and legend show layers. Why can't I use esri:map.layers and why can't the legend show layers of map when I use map.layers?

share|improve this question

Map.Layers refers to the layer collection in the application's code-behind. You don't need the esri:Map.Layers in your xaml code, because it understands that any child item in the esri:Map xml code will be a layer of some kind of layer.

If you want to manage layers in the code-behind, however, you would use Map.Layers.


<esri:Map x:Name="Map" >
    <esri:ArcGISDynamicMapServiceLayer ID="samplewebgis" 
          Url="http://m-pc/arcgis/rest/services/test/MapServer" />        

Code-behind (

Dim myLayer as New ArcGISDynamicMapServiceLayer("http://m-pc/arcgis/rest/services/test2/MapServer")
myLayer.ID = "samplewebgis_2"
share|improve this answer
i try your code but still i have same problem . – wetland Nov 20 '12 at 16:37

The first sample is not an ArcGISDynamicMapServiceLayer. It is a tiled map service. Try using <esri:ArcGISTiledMapServiceLayer ...

Writing about spatial software development

share|improve this answer
sorry . i edited my code . – wetland Nov 19 '12 at 20:21
i try your code . but have same problem . i also installed sp4 for arcgis desktop 10, arcgis server services,arcgis server web application but map legend does not show anything – wetland Nov 20 '12 at 16:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.