Select to view content in your preferred language

Deploying Silverlight website with different service URLs

774
3
11-16-2010 10:50 AM
DougCollins
Regular Contributor
Greetings,
I am trying to figure out if there is an accepted way to deploy an existing silverlight map website on one domain (ie the map services are on domain1 "services.abc.com") to another server on another domain (map services now are on domain2 "services.xyz.com").  One issue is that the URL for each map service must change to now point to domain2 in the XAML or code behind.  I have found that instead of using XAML, that I can use the code behind to define the layers and set the URL for each service.

My question now is it possible to set the MapTips for FeatureLayers using code behind?  Or is there an easier way to achieve this using XAML and code behind?

Thanks,
Charlie
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
My question now is it possible to set the MapTips for FeatureLayers using code behind?

Yes, MapTip can be set by code. Example :
 
TextBlock txtBlock = new TextBlock();
txtBlock.SetBinding(TextBlock.TextProperty, new Binding("[POP1990]"));
graphicLayer.MapTip = new Border() { Child = txtBlock, Background = new SolidColorBrush(Colors.White) };

That being said, I don't see why your maptip is depending on the URL but...


Or is there an easier way to achieve this using XAML and code behind?

Not sure it's better, but one option is you to create a resource dll including a resource dictionary with the parameters depending on the context, then you merge this dictionary in your project. So you have only the resource dll to change when deploying the application.

Example :

1) Create a new 'ResourceProject' with config.xaml file declared as 'Resource':
 
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
>
  <sys:String x:Key="baseLayerUrl">http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer</sys:String>
  <sys:String x:Key="featureLayerUrl">http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/2</sys:String>
</ResourceDictionary>


2) In your application, reference the resource project and merge the dictionary in your App.xaml file:
 
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
x:Class="ESRI.ArcGIS.Tests.Legend.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries> 
<ResourceDictionary Source="Styles/Styles.xaml" />
<ResourceDictionary Source="Styles/NavigationStyle.xaml" />
<ResourceDictionary Source="/ResourceProject;Component/config.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>


3) In your application, use the parameters as static resource:
Example:
 
Url="{StaticResource baseLayerUrl}"
0 Kudos
DougCollins
Regular Contributor
Thanks for the reply Dominique.
Every time I have seen MapTips used in XAML, the MapTip is always a subelement of a FeatureLayer which seems to require a "Url" field.  For example,

<esri:FeatureLayer ID="MyLayer"
         Url="http://server.com/ArcGIS/rest/services/xyzLayer/FeatureServer/0">
  <esri:FeatureLayer.MapTip>
     ...

Is it possible to define a MapTip in XAML without being a subelement of <esri:FeatureLayer>?

Also is it possible to define a <esri:FeatureLayer> element without specifying a Url field?

Thanks,
Charlie
0 Kudos
dotMorten_esri
Esri Notable Contributor
FeatureLayer only works with a feature service, so URL is required. If you don't want to work with a featureservice, use the GraphicsLayer.

You can define a maptip as a separate usercontrol and just reference that on the featurelayer or graphicslayer:
<esri:FeatureLayer.MapTip>
     <local:MyMapTipUserControl />
</esri:FeatureLayer.MapTip>
0 Kudos