Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have defined a simple tiled map service layer:

<esri:ArcGISTiledMapServiceLayer x:Name="BaseMap"
ID="BaseMap" Opacity="50" Initialized="MapServiceLayer_Initialized"
InitializationFailed="Layer_InitializationFailed" />

Then I assign its Url property programmatically:

BaseMap.Url = App._componentDict["BaseMapRestUrl"];

The app bombs with this message, and the entire Silverlight app goes blank:

Layer 'BaseMap' is currently unavailable. Error" Value cannot be null. Parameter name: Url


Is there a particular way to go about this that I'm missing? I suspect I'm setting the Url too late in the lifecycle.

share|improve this question
Since you're relying on code-behind anyway, why not just add the layer there instead of in xaml? –  Kirk Kuykendall May 3 '11 at 21:56
@Kirk - that worked. Seems like defining the Url property at runtime is not supported. –  nw1 May 4 '11 at 15:21
You can using event triggers. For an example of that create a new project using the Esri Standard Map Application project template, then look at the Base Map Switcher section of MainPage.xaml. –  Kirk Kuykendall May 4 '11 at 15:33

2 Answers 2

up vote 2 down vote accepted

Following Kirk's suggestion in the comments, I just did this:

// add base map layer
ArcGISTiledMapServiceLayer baseMap = new ArcGISTiledMapServiceLayer();
baseMap.Url = App._componentDict["BaseMapRestUrl"];
baseMap.ID = "BaseMap";
baseMap.Opacity = 50;
baseMap.Initialized += MapServiceLayer_Initialized;
baseMap.InitializationFailed += MapServiceLayer_InitializationFailed;

It worked great.

share|improve this answer
Great to see you post your working solution. Thanks for showing what worked. –  D.E.Wright May 9 '11 at 17:07

To set the url at runtime you might consider using a trigger action, as illustrated in Esri's Standard Map Application project template (under the Silverlight folder when you create a new project in visual studio).

This is from the Base Map Switcher section of MainPage.xaml:

<RadioButton Content="Streets" IsChecked="True"
    ToolTipService.ToolTip="Worldwide Street Map"
    Margin="5,0,0,0" Foreground="White" FontSize="11" >
        <i:EventTrigger EventName="Checked">
            <actions:SetLayerUrlAction TargetName="Map" LayerID="BaseLayer" 
<RadioButton Content="Topo"
    ToolTipService.ToolTip="United States Topographic Map"
    Margin="5,0,0,0" Foreground="White" FontSize="11" >
        <i:EventTrigger EventName="Checked">
            <actions:SetLayerUrlAction TargetName="Map" LayerID="BaseLayer" 
share|improve this answer

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.