<Application ... xmlns:clr="clr-namespace:System;assembly=mscorlib"> <Application.Resources> <sys:String x:Key="BingKeyString">abc...123</sys:String> </Application.Resources>
The string from your server is all you need. Also, the replacement you tried is invalid (you need to assign the value of BingKeyString wherever it is defined, probably in App.xaml:<Application ... xmlns:clr="clr-namespace:System;assembly=mscorlib"> <Application.Resources> <sys:String x:Key="BingKeyString">abc...123</sys:String> </Application.Resources>
Thank you for your advice. I tried to change my code to this:
<UserControl x:Class="bing.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"
xmlns:bing="clr-namespace:ESRI.ArcGIS.Client.Bing;assembly=ESRI.ArcGIS.Client.Bing">
xmlns:clr="clr-namespace:System;assembly=mscorlib">
<Application.Resources>
<sys:String x:Key="BingKeyString">abc123</sys:String>
</Application.Resources>
<Grid x:Name="LayoutRoot">
<esri:Map x:Name="MyMap">
<!-- Replace Token value with your Bing Maps key. Use http://www.bingmapsportal.com to generate a key. -->
<bing:TileLayer ID="BingLayer" LayerStyle="Road" Visible="True" ServerType="Production"
Token="{StaticResource BingMapsKey}" />
</esri:Map>
<Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" >
<Rectangle Fill="#77919191" Stroke="Gray" RadiusX="10" RadiusY="10" Margin="0" >
<Rectangle.Effect>
<DropShadowEffect/>
</Rectangle.Effect>
</Rectangle>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5" >
<RadioButton x:Name="RoadRadioButton"
Tag="Road" IsChecked="true" Margin="5,0,0,0" Foreground="White"
GroupName="Layers" Content="Road" Click="RadioButton_Click"/>
<RadioButton x:Name="AerialRadioButton"
Tag="Aerial" Margin="5,0,0,0" Foreground="White"
GroupName="Layers" Content="Aerial" Click="RadioButton_Click"/>
<RadioButton x:Name="AerialWithLabelsRadioButton"
Tag="AerialWithLabels" Margin="5,0,0,0" Foreground="White"
GroupName="Layers" Content="Aerial - Labels" Click="RadioButton_Click"/>
</StackPanel>
</Grid>
</Grid>
</UserControl>
And I received following errors:
Error 1 'sys' is an undeclared prefix.
Error 4 A value of type 'String' cannot be added a child of type 'UIElement'.
Error 2 The attachable property 'Resources' was not found in type 'Application'.
Error 5 The property 'Content' is set more than once.
Error 3 The type 'sys:String' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
Oh, I see. You should change:
<Application.Resources>
<sys:String x:Key="BingKeyString">abc123</sys:String>
</Application.Resources>
to
<UserControl.Resources>
<sys:String x:Key="BingKeyString">abc123</sys:String>
</UserControl.Resources>