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}"