Creating a Visual Studio LightSwitch Custom Silverlight Control (Using Infragistics Components)

[Infragistics] Mihail Mateev / Saturday, September 4, 2010

Using Visual Studio LightSwitch, you have a possibility in the use of Custom Silverlight Controls. With a Custom Silverlight Control, you can implement functionality that is outside the normal abilities of LightSwitch.

The first question if some company has an interest in Visual Studio LightSwitch applications is how to now be re-written as a regular Silverlight application because it “can’t perform the new requirements”.

To extent a Visual Studio LightSwitch application you may find that in most cases, you just need to create Silverlight Custom Controls, and plug them into LightSwitch.

Note: you need Visual Studio Professional (or higher) to create Custom Silverlight Controls.

This article demonstrates how to use a ready to use Silverlight Custom Control in Visual Studio LightSwitch.

The LightSwitch Sample Project

Requirements:

Software:
•    Visual Studio 2010
•    Visual Studio LightSwitch Beta 1: details.aspx-FamilyID=37551a54-bfd3-4af6-a513-676bbb2dfb69&displaylang=en
•    Infragistics XamMap component:  NetAdvantage for Silverlight Data Visualization 2010 vol.2
http://es.infragistics.com/dotnet/netadvantage/silverlight/data-visualization.aspx#Downloads

Sample data:

 

Demo application is based on an application, used for the article:"Introduction to Visual Studio LightSwitch”

 

Steps to cerate a sample application:

  • Get a sample from article: "Introduction to Visual Studio LightSwitch”
  • In the LightSwitch application add in IGCustomers table a field, named Country.
  • Add a new project from type Silverlight Class Library named XamMapLibrary
  • Add a new item (Silverlight User Control) to the project, named XamMapControl
  • Implement additional logic in the XamMapControl to highlight a country by name.
  • Add a new Silverlight User Control to the project, named LightSwitchMap. This  control will contain
    code for binding to specific properties from the screen DataContext.
  • Run the application

 

Get a sample from article: "Introduction to Visual Studio LightSwitch”

 

In the LightSwitch application add in IGCustomers table a field, named Country. 

Add a new project from type Silverlight Class Library named XamMapLibrary

Add a new item (Silverlight User Control) to the project, named XamMapControl

Copy a code from a sample application for the article "Customizing the XamMap MapNavigationPane Control Template"

   1: <UserControl x:Class="XamMapLibrary.XamMapControl"
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   5:     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ig="clr-namespace:Infragistics.Controls.Maps;assembly=InfragisticsSL4.Controls.Maps.XamMap.v10.2" mc:Ignorable="d"
   6:     d:DesignHeight="300" d:DesignWidth="400">
   7:     <UserControl.Resources>
   8:         <LinearGradientBrush x:Key="PanCtrlBackgroundFill" EndPoint="0.5,1" StartPoint="0.5,0">
   9:             <GradientStop Color="#FFffffff" Offset="0"/>
  10:             <GradientStop Color="#FFf8f9fa" Offset="0.28888899087905884"/>
  11:             <GradientStop Color="#FFd9dee2" Offset="0.7555559873580933"/>
  12:             <GradientStop Color="#FFcfd5da" Offset="0.9833329916000366"/>
  13:         </LinearGradientBrush>
  14:         <LinearGradientBrush x:Key="NaviBorderFill" EndPoint="0.5,1" StartPoint="0.5,0">
  15:             <GradientStop Color="#FFA3AEB9"/>
  16:             <GradientStop Color="#FF617584" Offset="1"/>
  17:         </LinearGradientBrush>
  18:         <LinearGradientBrush x:Key="GenericBackgroundGradient" EndPoint=".7,1" StartPoint=".7,0">
  19:             <GradientStop Color="#00000000" Offset="0"/>
  20:             <GradientStop Color="#06000000" Offset="0.375"/>
  21:             <GradientStop Color="#1a000000" Offset="0.625"/>
  22:             <GradientStop Color="#39000000" Offset="1"/>
  23:         </LinearGradientBrush>
  24:         <Style x:Key="Arrow" TargetType="Button">
  25:             <Setter Property="IsEnabled" Value="true"/>
  26:             <Setter Property="IsTabStop" Value="true"/>
  27:             <Setter Property="Background" Value="#FF003255"/>
  28:             <Setter Property="Foreground" Value="#FF808080"/>
  29:             <Setter Property="MinWidth" Value="12"/>
  30:             <Setter Property="MinHeight" Value="8"/>
  31:             <Setter Property="Margin" Value="0"/>
  32:             <Setter Property="HorizontalContentAlignment" Value="Center"/>
  33:             <Setter Property="VerticalContentAlignment" Value="Center"/>
  34:             <Setter Property="Cursor" Value="Arrow"/>
  35:             <Setter Property="FontSize" Value="11"/>
  36:             <Setter Property="Template">
  37:                 <Setter.Value>
  38:                     <ControlTemplate TargetType="Button">
  39:                         <Grid x:Name="grid" Background="#00FFFFFF">
  40:                             <VisualStateManager.VisualStateGroups>
  41:                                 <VisualStateGroup x:Name="CommonStates">
  42:                                     <VisualState x:Name="Normal">
  43:                                         <Storyboard/>
  44:                                     </VisualState>
  45:                                     <VisualState x:Name="MouseOver">
  46:                                         <Storyboard>
  47:                                             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="pathMouseOver">
  48:                                                 <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="-3"/>
  49:                                             </DoubleAnimationUsingKeyFrames>
  50:                                             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="pathMouseOver">
  51:                                                 <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
  52:                                             </DoubleAnimationUsingKeyFrames>
  53:                                             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="path">
  54:                                                 <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="3"/>
  55:                                             </DoubleAnimationUsingKeyFrames>
  56:                                         </Storyboard>
  57:                                     </VisualState>
  58:                                     <VisualState x:Name="Pressed">
  59:                                         <Storyboard>
  60:                                             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="pathMouseOver">
  61:                                                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="-3"/>
  62:                                             </DoubleAnimationUsingKeyFrames>
  63:                                             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="pathMouseOver">
  64:                                                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
  65:                                             </DoubleAnimationUsingKeyFrames>
  66:                                             <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path">
  67:                                                 <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF00A8FF"/>
  68:                                             </ColorAnimationUsingKeyFrames>
  69:                                             <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="pathMouseOver">
  70:                                                 <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF00A8FF"/>
  71:                                             </ColorAnimationUsingKeyFrames>
  72:                                             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="path">
  73:                                                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="3"/>
  74:                                             </DoubleAnimationUsingKeyFrames>
  75:                                         </Storyboard>
  76:                                     </VisualState>
  77:                                     <VisualState x:Name="Disabled"/>
  78:                                 </VisualStateGroup>
  79:                             </VisualStateManager.VisualStateGroups>
  80:                             <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="Stretch" Margin="4,5,4,4" Visibility="Collapsed" VerticalAlignment="Stretch" d:IsHidden="True"/>
  81:                             <Path x:Name="path" Data="M 68,30 C68,30 62,36 62,36 62,36 64,38 64,38 64,38 68,34 68,34 68,34 72,38 72,38 72,38 74,36 74,36 74,36 68,30 68,30 z" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Center" Height="8" Opacity="1" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Center" Width="12">
  82:                                 <Path.RenderTransform>
  83:                                     <TransformGroup>
  84:                                         <ScaleTransform/>
  85:                                         <SkewTransform/>
  86:                                         <RotateTransform/>
  87:                                         <TranslateTransform/>
  88:                                     </TransformGroup>
  89:                                 </Path.RenderTransform>
  90:                             </Path>
  91:                             <Path x:Name="pathMouseOver" Data="M 68,30 C68,30 62,36 62,36 62,36 64,38 64,38 64,38 68,34 68,34 68,34 72,38 72,38 72,38 74,36 74,36 74,36 68,30 68,30 z" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Stretch" Height="8" Opacity="0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Stretch" Width="12" d:LayoutOverrides="Height">
  92:                                 <Path.RenderTransform>
  93:                                     <TransformGroup>
  94:                                         <ScaleTransform/>
  95:                                         <SkewTransform/>
  96:                                         <RotateTransform/>
  97:                                         <TranslateTransform/>
  98:                                     </TransformGroup>
  99:                                 </Path.RenderTransform>
 100:                             </Path>
 101:                         </Grid>
 102:                     </ControlTemplate>
 103:                 </Setter.Value>
 104:             </Setter>
 105:         </Style>
 106:         <LinearGradientBrush x:Key="FitBtnGlyphForegroundFill" EndPoint="0.7009506225585938,0.8659271240234375" StartPoint="0.4,0.2">
 107:             <LinearGradientBrush.GradientStops>
 108:                 <GradientStopCollection>
 109:                     <GradientStop Color="#FF666666" Offset="0"/>
 110:                     <GradientStop Color="#FF8695a4" Offset="1"/>
 111:                 </GradientStopCollection>
 112:             </LinearGradientBrush.GradientStops>
 113:         </LinearGradientBrush>
 114:         <LinearGradientBrush x:Key="FitBtnOuterBevelFill" EndPoint="0.5,1" StartPoint="0.5,0">
 115:             <LinearGradientBrush.GradientStops>
 116:                 <GradientStopCollection>
 117:                     <GradientStop Color="#FFa7afb6" Offset="0"/>
 118:                     <GradientStop Color="#FFffffff" Offset="0.5"/>
 119:                     <GradientStop Color="#FFffffff" Offset="1"/>
 120:                 </GradientStopCollection>
 121:             </LinearGradientBrush.GradientStops>
 122:         </LinearGradientBrush>
 123:         <LinearGradientBrush x:Key="FitBtnCenterFill" EndPoint="0.5,1" StartPoint="0.5,0">
 124:             <LinearGradientBrush.GradientStops>
 125:                 <GradientStopCollection>
 126:                     <GradientStop Color="#FFf6f7f8" Offset="0"/>
 127:                     <GradientStop Color="#FF8f9da9" Offset="1"/>
 128:                 </GradientStopCollection>
 129:             </LinearGradientBrush.GradientStops>
 130:         </LinearGradientBrush>
 131:         <SolidColorBrush x:Key="FitBtnCenterBorderFill" Color="#FF8594A3"/>
 132:         <Style x:Key="FitBtn" TargetType="Button">
 133:             <Setter Property="IsEnabled" Value="true"/>
 134:             <Setter Property="IsTabStop" Value="true"/>
 135:             <Setter Property="Background" Value="#FF003255"/>
 136:             <Setter Property="Foreground" Value="{StaticResource FitBtnGlyphForegroundFill}"/>
 137:             <Setter Property="MinWidth" Value="5"/>
 138:             <Setter Property="MinHeight" Value="5"/>
 139:             <Setter Property="Margin" Value="0"/>
 140:             <Setter Property="HorizontalContentAlignment" Value="Center"/>
 141:             <Setter Property="VerticalContentAlignment" Value="Center"/>
 142:             <Setter Property="Cursor" Value="Arrow"/>
 143:             <Setter Property="FontSize" Value="11"/>
 144:             <Setter Property="Template">
 145:                 <Setter.Value>
 146:                     <ControlTemplate TargetType="Button">
 147:                         <Grid>
 148:                             <VisualStateManager.VisualStateGroups>
 149:                                 <VisualStateGroup x:Name="CommonStates">
 150:                                     <VisualState x:Name="Normal"/>
 151:                                     <VisualState x:Name="MouseOver">
 152:                                         <Storyboard/>
 153:                                     </VisualState>
 154:                                     <VisualState x:Name="Pressed">
 155:                                         <Storyboard/>
 156:                                     </VisualState>
 157:                                     <VisualState x:Name="Disabled">
 158:                                         <Storyboard/>
 159:                                     </VisualState>
 160:                                 </VisualStateGroup>
 161:                             </VisualStateManager.VisualStateGroups>
 162:                             <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Margin="4,5,4,4" Visibility="Collapsed"/>
 163:                             <Ellipse x:Name="OuterBevel" Fill="{StaticResource FitBtnOuterBevelFill}"/>
 164:                             <Ellipse Fill="{StaticResource FitBtnCenterFill}" Margin="1,1,1,1" Stroke="{StaticResource FitBtnCenterBorderFill}"/>
 165:                             <Path x:Name="pathShdw" Data="M2,0 L3,0 L3,2 L5,2 L5,3 L3,3 L3,5 L2,5 L2,3 L0,3 L0,2 L2,2 L2,0 z" Fill="#99FFFFFF" HorizontalAlignment="Stretch" Margin="6,6,4,4" Stretch="Fill" VerticalAlignment="Stretch"/>
 166:                             <Path x:Name="path" Data="M2,0 L3,0 L3,2 L5,2 L5,3 L3,3 L3,5 L2,5 L2,3 L0,3 L0,2 L2,2 L2,0 z" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Stretch" Margin="5,5,5,5" Stretch="Fill" VerticalAlignment="Stretch"/>
 167:                         </Grid>
 168:                     </ControlTemplate>
 169:                 </Setter.Value>
 170:             </Setter>
 171:         </Style>
 172:         <LinearGradientBrush x:Key="BorderFill" EndPoint="0.5,1" StartPoint="0.5,0">
 173:             <GradientStop Color="#FFA3AEB9"/>
 174:             <GradientStop Color="#FF8399A9" Offset="0.375"/>
 175:             <GradientStop Color="#FF718597" Offset="0.375"/>
 176:             <GradientStop Color="#FF617584" Offset="1"/>
 177:         </LinearGradientBrush>
 178:         <Style x:Key="ZoomOut" TargetType="Button">
 179:             <Setter Property="IsEnabled" Value="true"/>
 180:             <Setter Property="IsTabStop" Value="true"/>
 181:             <Setter Property="Background" Value="#FF003255"/>
 182:             <Setter Property="Foreground" Value="{StaticResource BorderFill}"/>
 183:             <Setter Property="MinWidth" Value="5"/>
 184:             <Setter Property="MinHeight" Value="5"/>
 185:             <Setter Property="Margin" Value="0"/>
 186:             <Setter Property="HorizontalContentAlignment" Value="Center"/>
 187:             <Setter Property="VerticalContentAlignment" Value="Center"/>
 188:             <Setter Property="Cursor" Value="Arrow"/>
 189:             <Setter Property="FontSize" Value="11"/>
 190:             <Setter Property="Template">
 191:                 <Setter.Value>
 192:                     <ControlTemplate TargetType="Button">
 193:                         <Grid Background="#00FFFFFF">
 194:                             <VisualStateManager.VisualStateGroups>
 195:                                 <VisualStateGroup x:Name="CommonStates">
 196:                                     <VisualState x:Name="Normal">
 197:                                         <Storyboard/>
 198:                                     </VisualState>
 199:                                     <VisualState x:Name="MouseOver">
 200:                                         <Storyboard/>
 201:                                     </VisualState>
 202:                                     <VisualState x:Name="Pressed">
 203:                                         <Storyboard/>
 204:                                     </VisualState>
 205:                                     <VisualState x:Name="Disabled"/>
 206:                                 </VisualStateGroup>
 207:                             </VisualStateManager.VisualStateGroups>
 208:                             <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="Stretch" Visibility="Collapsed" VerticalAlignment="Stretch"/>
 209:                             <Rectangle x:Name="rectangleShdw" Fill="#FFFFFFFF" HorizontalAlignment="Center" Height="2" VerticalAlignment="Center" Width="10"/>
 210:                             <Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Center" Height="2" Margin="0,0,0,2" VerticalAlignment="Center" Width="10"/>
 211:                         </Grid>
 212:                     </ControlTemplate>
 213:                 </Setter.Value>
 214:             </Setter>
 215:         </Style>
 216:         <LinearGradientBrush x:Key="ZoomPaneSliderOuterBevelTopFill" EndPoint="1,1" StartPoint="0,0">
 217:             <LinearGradientBrush.GradientStops>
 218:                 <GradientStopCollection>
 219:                     <GradientStop Color="#FFc2cad0" Offset="0"/>
 220:                     <GradientStop Color="#FFFFFFFF" Offset="1"/>
 221:                     <GradientStop Color="#FFDCE0E4" Offset="0.605"/>
 222:                 </GradientStopCollection>
 223:             </LinearGradientBrush.GradientStops>
 224:         </LinearGradientBrush>
 225:         <Style x:Key="ZoomIn" TargetType="Button">
 226:             <Setter Property="IsEnabled" Value="true"/>
 227:             <Setter Property="IsTabStop" Value="true"/>
 228:             <Setter Property="Background" Value="#FF003255"/>
 229:             <Setter Property="Foreground" Value="{StaticResource BorderFill}"/>
 230:             <Setter Property="MinWidth" Value="5"/>
 231:             <Setter Property="MinHeight" Value="5"/>
 232:             <Setter Property="Margin" Value="0"/>
 233:             <Setter Property="HorizontalContentAlignment" Value="Center"/>
 234:             <Setter Property="VerticalContentAlignment" Value="Center"/>
 235:             <Setter Property="Cursor" Value="Arrow"/>
 236:             <Setter Property="FontSize" Value="11"/>
 237:             <Setter Property="Template">
 238:                 <Setter.Value>
 239:                     <ControlTemplate TargetType="Button">
 240:                         <Grid Background="#00FFFFFF">
 241:                             <VisualStateManager.VisualStateGroups>
 242:                                 <VisualStateGroup x:Name="CommonStates">
 243:                                     <VisualState x:Name="Normal">
 244:                                         <Storyboard/>
 245:                                     </VisualState>
 246:                                     <VisualState x:Name="MouseOver">
 247:                                         <Storyboard/>
 248:                                     </VisualState>
 249:                                     <VisualState x:Name="Pressed">
 250:                                         <Storyboard/>
 251:                                     </VisualState>
 252:                                     <VisualState x:Name="Disabled"/>
 253:                                 </VisualStateGroup>
 254:                             </VisualStateManager.VisualStateGroups>
 255:                             <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="Stretch" Visibility="Collapsed" VerticalAlignment="Stretch"/>
 256:                             <Path x:Name="pathShdw" Data="M2,0 L3,0 L3,2 L5,2 L5,3 L3,3 L3,5 L2,5 L2,3 L0,3 L0,2 L2,2 L2,0 z" Fill="#FFFFFFFF" HorizontalAlignment="Stretch" Height="10" Margin="0,1,0,0" Stretch="Fill" VerticalAlignment="Stretch" Width="10"/>
 257:                             <Path x:Name="path" Data="M2,0 L3,0 L3,2 L5,2 L5,3 L3,3 L3,5 L2,5 L2,3 L0,3 L0,2 L2,2 L2,0 z" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Stretch" Height="10" Stretch="Fill" VerticalAlignment="Stretch" Width="10"/>
 258:                         </Grid>
 259:                     </ControlTemplate>
 260:                 </Setter.Value>
 261:             </Setter>
 262:         </Style>
 263:         <LinearGradientBrush x:Key="ZoomPaneSliderOuterBevelBottomFill" EndPoint="1,1" StartPoint="0,.5">
 264:             <LinearGradientBrush.GradientStops>
 265:                 <GradientStopCollection>
 266:                     <GradientStop Color="#FFD4DADE" Offset="0.2"/>
 267:                     <GradientStop Color="#FFFFFFFF" Offset="0.577"/>
 268:                     <GradientStop Color="#FFD4DADE" Offset="0.95"/>
 269:                     <GradientStop Color="#FFFFFFFF" Offset="0.655"/>
 270:                 </GradientStopCollection>
 271:             </LinearGradientBrush.GradientStops>
 272:         </LinearGradientBrush>
 273:         <LinearGradientBrush x:Key="ZoomPaneSliderBorderFill" EndPoint="0,1" StartPoint="0,0">
 274:             <LinearGradientBrush.GradientStops>
 275:                 <GradientStopCollection>
 276:                     <GradientStop Color="#FF8594a3" Offset="0"/>
 277:                     <GradientStop Color="#FFa3aeb9" Offset="1"/>
 278:                 </GradientStopCollection>
 279:             </LinearGradientBrush.GradientStops>
 280:         </LinearGradientBrush>
 281:         <LinearGradientBrush x:Key="ZoomPaneSliderOverlayFill" EndPoint="0.5,1" StartPoint="0.5,0">
 282:             <LinearGradientBrush.GradientStops>
 283:                 <GradientStopCollection>
 284:                     <GradientStop Color="#FFffffff" Offset="0"/>
 285:                     <GradientStop Color="#f1ffffff" Offset="0.3700000047683716"/>
 286:                     <GradientStop Color="#e4ffffff" Offset="0.6299999952316284"/>
 287:                     <GradientStop Color="#ccffffff" Offset="1"/>
 288:                 </GradientStopCollection>
 289:             </LinearGradientBrush.GradientStops>
 290:         </LinearGradientBrush>
 291:         <LinearGradientBrush x:Key="SliderTrackBackgroundFill" EndPoint="1,0" StartPoint="0,0">
 292:             <LinearGradientBrush.GradientStops>
 293:                 <GradientStopCollection>
 294:                     <GradientStop Color="#FFd3d8dd" Offset="1"/>
 295:                     <GradientStop Color="#FFfafafb" Offset="0"/>
 296:                 </GradientStopCollection>
 297:             </LinearGradientBrush.GradientStops>
 298:         </LinearGradientBrush>
 299:         <SolidColorBrush x:Key="SliderTrackRailBorderFill" Color="#FFA2ACB7"/>
 300:         <LinearGradientBrush x:Key="SliderTrackRailBackgroundFill" EndPoint="1,0" StartPoint="0,0">
 301:             <LinearGradientBrush.GradientStops>
 302:                 <GradientStopCollection>
 303:                     <GradientStop Color="#FFd3d9dd" Offset="0"/>
 304:                     <GradientStop Color="#FFffffff" Offset="0.75"/>
 305:                     <GradientStop Color="#FFffffff" Offset="1"/>
 306:                 </GradientStopCollection>
 307:             </LinearGradientBrush.GradientStops>
 308:         </LinearGradientBrush>
 309:         <LinearGradientBrush x:Key="ZoomRangeThumbCenterFill" EndPoint="0.5,1" StartPoint="0.5,0">
 310:             <LinearGradientBrush.GradientStops>
 311:                 <GradientStopCollection>
 312:                     <GradientStop Color="#FFffffff" Offset="0"/>
 313:                     <GradientStop Color="#FFa3aeb9" Offset="1"/>
 314:                 </GradientStopCollection>
 315:             </LinearGradientBrush.GradientStops>
 316:         </LinearGradientBrush>
 317:         <SolidColorBrush x:Key="ZoomRangeThumbBorderFill" Color="#FF8399A9"/>
 318:         <SolidColorBrush x:Key="ZoomRangeThumbHighlightFill" Color="#FFFFFFFF"/>
 319:         <ControlTemplate x:Key="ZoomRangeThumb" TargetType="Thumb">
 320:             <Grid>
 321:                 <Ellipse Fill="{StaticResource ZoomRangeThumbCenterFill}" Stroke="{StaticResource ZoomRangeThumbBorderFill}"/>
 322:                 <Ellipse HorizontalAlignment="Stretch" Margin="1,1,1,1" Stroke="{StaticResource ZoomRangeThumbHighlightFill}" VerticalAlignment="Stretch"/>
 323:             </Grid>
 324:         </ControlTemplate>
 325:         <Style x:Key="ZoomRange" TargetType="Slider">
 326:             <Setter Property="Template">
 327:                 <Setter.Value>
 328:                     <ControlTemplate TargetType="Slider">
 329:                         <Grid x:Name="Root">
 330:                             <Grid.Resources>
 331:                                 <ControlTemplate x:Key="RepeatButtonTemplate">
 332:                                     <Grid x:Name="Root" Background="Transparent" Opacity="0"/>
 333:                                 </ControlTemplate>
 334:                             </Grid.Resources>
 335:                             <VisualStateManager.VisualStateGroups>
 336:                                 <VisualStateGroup x:Name="CommonStates">
 337:                                     <VisualStateGroup.Transitions>
 338:                                         <VisualTransition GeneratedDuration="0"/>
 339:                                     </VisualStateGroup.Transitions>
 340:                                     <VisualState x:Name="Normal">
 341:                                         <Storyboard/>
 342:                                     </VisualState>
 343:                                     <VisualState x:Name="MouseOver">
 344:                                         <Storyboard/>
 345:                                     </VisualState>
 346:                                     <VisualState x:Name="Disabled">
 347:                                         <Storyboard>
 348:                                             <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
 349:                                         </Storyboard>
 350:                                     </VisualState>
 351:                                 </VisualStateGroup>
 352:                                 <VisualStateGroup x:Name="FocusStates">
 353:                                     <VisualStateGroup.Transitions>
 354:                                         <VisualTransition GeneratedDuration="0"/>
 355:                                     </VisualStateGroup.Transitions>
 356:                                     <VisualState x:Name="Unfocused">
 357:                                         <Storyboard/>
 358:                                     </VisualState>
 359:                                     <VisualState x:Name="Focused">
 360:                                         <Storyboard>
 361:                                             <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisual"/>
 362:                                         </Storyboard>
 363:                                     </VisualState>
 364:                                 </VisualStateGroup>
 365:                             </VisualStateManager.VisualStateGroups>
 366:                             <Grid x:Name="HorizontalTemplate">
 367:                                 <Grid.ColumnDefinitions>
 368:                                     <ColumnDefinition Width="Auto"/>
 369:                                     <ColumnDefinition Width="Auto"/>
 370:                                     <ColumnDefinition Width="*"/>
 371:                                 </Grid.ColumnDefinitions>
 372:                                 <Rectangle Grid.ColumnSpan="3" Grid.Column="0" Fill="#FFE6EFF7" Height="3" Margin="5,0,5,0" Stroke="Black" StrokeThickness="0.5"/>
 373:                                 <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Grid.Column="0" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}"/>
 374:                                 <Thumb x:Name="HorizontalThumb" Grid.Column="1" Height="18" Width="11"/>
 375:                                 <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Grid.Column="2" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}"/>
 376:                             </Grid>
 377:                             <Grid x:Name="VerticalTemplate" Visibility="Collapsed">
 378:                                 <Grid.RowDefinitions>
 379:                                     <RowDefinition Height="*"/>
 380:                                     <RowDefinition Height="Auto"/>
 381:                                     <RowDefinition Height="Auto"/>
 382:                                 </Grid.RowDefinitions>
 383:                                 <Border BorderBrush="{StaticResource SliderTrackRailBorderFill}" BorderThickness="1,0,0,0" Background="{StaticResource SliderTrackRailBackgroundFill}" CornerRadius="4,4,4,4" Height="Auto" Grid.Row="0" Grid.RowSpan="3" VerticalAlignment="Stretch" Width="8"/>
 384:                                 <RepeatButton x:Name="VerticalTrackLargeChangeDecreaseRepeatButton" IsTabStop="False" Grid.RowSpan="3" Template="{StaticResource RepeatButtonTemplate}"/>
 385:                                 <Thumb x:Name="VerticalThumb" Height="12" Grid.Row="1" Template="{StaticResource ZoomRangeThumb}" Width="12"/>
 386:                                 <RepeatButton x:Name="VerticalTrackLargeChangeIncreaseRepeatButton" IsTabStop="False" Grid.Row="0" Template="{StaticResource RepeatButtonTemplate}"/>
 387:                             </Grid>
 388:                             <Rectangle x:Name="FocusVisual" IsHitTestVisible="false" Opacity="0" StrokeDashCap="Round" Stroke="#666666" StrokeDashArray=".2 5" Visibility="Collapsed"/>
 389:                         </Grid>
 390:                     </ControlTemplate>
 391:                 </Setter.Value>
 392:             </Setter>
 393:             <Setter Property="Orientation" Value="Vertical"/>
 394:         </Style>
 395:         <SolidColorBrush x:Key="ZoomBtnBorderFill" Color="#FFA3AEB9"/>
 396:         <LinearGradientBrush x:Key="ZoomBtnCenterFill" EndPoint="1,1" StartPoint="0,0">
 397:             <LinearGradientBrush.GradientStops>
 398:                 <GradientStopCollection>
 399:                     <GradientStop Color="#FFfbfcfc" Offset="0"/>
 400:                     <GradientStop Color="#FFc2c9d0" Offset="1"/>
 401:                 </GradientStopCollection>
 402:             </LinearGradientBrush.GradientStops>
 403:         </LinearGradientBrush>
 404:         <ig:SRProvider x:Key="SR"/>
 405:         <LinearGradientBrush x:Key="PanPaneInnerBorderFill" EndPoint="0.5,1" StartPoint="0.5,0">
 406:             <LinearGradientBrush.GradientStops>
 407:                 <GradientStopCollection>
 408:                     <GradientStop Color="#FFffffff" Offset="0"/>
 409:                     <GradientStop Color="#bfffffff" Offset="0.5"/>
 410:                     <GradientStop Color="#00ffffff" Offset="1"/>
 411:                 </GradientStopCollection>
 412:             </LinearGradientBrush.GradientStops>
 413:         </LinearGradientBrush>
 414:         <LinearGradientBrush x:Key="BaseBgDarkInnerBorder" EndPoint="0.5,1" StartPoint="0.5,0">
 415:             <LinearGradientBrush.GradientStops>
 416:                 <GradientStopCollection>
 417:                     <GradientStop Color="#FF8594a3" Offset="0"/>
 418:                     <GradientStop Color="#FFc8cfd5" Offset="1"/>
 419:                 </GradientStopCollection>
 420:             </LinearGradientBrush.GradientStops>
 421:         </LinearGradientBrush>
 422:         <LinearGradientBrush x:Key="BaseBgCenterCircleLightBorderFill" EndPoint="0.5,1" StartPoint="0.5,0">
 423:             <LinearGradientBrush.GradientStops>
 424:                 <GradientStopCollection>
 425:                     <GradientStop Color="#00ffffff" Offset="0"/>
 426:                     <GradientStop Color="#FFffffff" Offset="0.75"/>
 427:                     <GradientStop Color="#FFffffff" Offset="1"/>
 428:                 </GradientStopCollection>
 429:             </LinearGradientBrush.GradientStops>
 430:         </LinearGradientBrush>
 431:         <LinearGradientBrush x:Key="BaseBgCenterCircleBackgroundFill" EndPoint="0,1" StartPoint="0,0">
 432:             <LinearGradientBrush.GradientStops>
 433:                 <GradientStopCollection>
 434:                     <GradientStop Color="#FFc8cfd5" Offset="0"/>
 435:                     <GradientStop Color="#FF5a6978" Offset="1"/>
 436:                 </GradientStopCollection>
 437:             </LinearGradientBrush.GradientStops>
 438:         </LinearGradientBrush>
 439:         <LinearGradientBrush x:Key="BasebgCenterCircleOverlay" EndPoint="0,0.9863013698630136" StartPoint="0,0">
 440:             <LinearGradientBrush.GradientStops>
 441:                 <GradientStopCollection>
 442:                     <GradientStop Color="#FFffffff" Offset="0"/>
 443:                     <GradientStop Color="#FFffffff" Offset="0.20000000298023224"/>
 444:                     <GradientStop Color="#f1ffffff" Offset="0.3700000047683716"/>
 445:                     <GradientStop Color="#DAffffff" Offset="0.6299999952316284"/>
 446:                     <GradientStop Color="#ccffffff" Offset="0.800000011920929"/>
 447:                     <GradientStop Color="#8cffffff" Offset="1"/>
 448:                 </GradientStopCollection>
 449:             </LinearGradientBrush.GradientStops>
 450:         </LinearGradientBrush>
 451:         <Style x:Key="MapNavigationPaneCustomStyle" TargetType="ig:MapNavigationPane">
 452:             <Setter Property="Background" Value="{StaticResource PanCtrlBackgroundFill}"/>
 453:             <Setter Property="BorderBrush" Value="{StaticResource NaviBorderFill}"/>
 454:             <Setter Property="Template">
 455:                 <Setter.Value>
 456:                     <ControlTemplate TargetType="ig:MapNavigationPane">
 457:                         <Grid>
 458:                             <Grid x:Name="HorizontalRoot">
 459:                                 <Grid.ColumnDefinitions>
 460:                                     <ColumnDefinition Width="auto"/>
 461:                                     <ColumnDefinition Width="auto"/>
 462:  
 463:                                     <ColumnDefinition Width="auto"/>
 464:                                     <ColumnDefinition Width="auto"/>
 465:                                     <ColumnDefinition Width="*"/>
 466:                                 </Grid.ColumnDefinitions>
 467:                                 <Rectangle Grid.ColumnSpan="5" Grid.Column="0" Fill="White" RadiusY="4" RadiusX="4"/>
 468:                                 <Rectangle Grid.ColumnSpan="5" Grid.Column="0" Fill="{StaticResource GenericBackgroundGradient}" RadiusY="4" RadiusX="4" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1.3"/>
 469:                                 <Grid x:Name="HorizontalPanControl" Grid.Column="0">
 470:                                     <Grid.ColumnDefinitions>
 471:                                         <ColumnDefinition Width="*"/>
 472:                                         <ColumnDefinition Width="*"/>
 473:                                         <ColumnDefinition Width="*"/>
 474:                                     </Grid.ColumnDefinitions>
 475:                                     <Grid.RowDefinitions>
 476:                                         <RowDefinition Height="*"/>
 477:                                         <RowDefinition Height="*"/>
 478:                                         <RowDefinition Height="*"/>
 479:                                     </Grid.RowDefinitions>
 480:                                     <Button x:Name="HorizontalPanWestButton" Content="W" Grid.Column="0" Height="20" Grid.Row="1" RenderTransformOrigin="0.5,0.5" Style="{StaticResource Arrow}" Width="20">
 481:                                         <Button.RenderTransform>
 482:                                             <TransformGroup>
 483:                                                 <ScaleTransform/>
 484:                                                 <SkewTransform/>
 485:                                                 <RotateTransform Angle="-90"/>
 486:                                                 <TranslateTransform/>
 487:                                             </TransformGroup>
 488:                                         </Button.RenderTransform>
 489:                                     </Button>
 490:                                     <Button x:Name="HorizontalPanSouthButton" Content="S" Grid.Column="1" Height="20" Grid.Row="2" RenderTransformOrigin="0.5,0.5" Style="{StaticResource Arrow}" Width="20">
 491:                                         <Button.RenderTransform>
 492:                                             <TransformGroup>
 493:                                                 <ScaleTransform ScaleY="-1"/>
 494:                                                 <SkewTransform/>
 495:                                                 <RotateTransform/>
 496:                                                 <TranslateTransform/>
 497:                                             </TransformGroup>
 498:                                         </Button.RenderTransform>
 499:                                     </Button>
 500:                                     <Button x:Name="HorizontalPanEastButton" Content="E" Grid.Column="2" Height="20" Grid.Row="1" RenderTransformOrigin="0.5,0.5" Style="{StaticResource Arrow}" Width="20">
 501:                                         <Button.RenderTransform>
 502:                                             <TransformGroup>
 503:                                                 <ScaleTransform/>
 504:                                                 <SkewTransform/>
 505:                                                 <RotateTransform Angle="90"/>
 506:                                                 <TranslateTransform/>
 507:                                             </TransformGroup>
 508:                                         </Button.RenderTransform>
 509:                                     </Button>
 510:                                     <Button x:Name="HorizontalPanNorthButton" Content="N" Grid.Column="1" Height="20" Grid.Row="0" Style="{StaticResource Arrow}" Width="20"/>
 511:                                     <Button x:Name="HorizontalFitButton" Grid.Column="1" Height="20" Grid.Row="1" Style="{StaticResource FitBtn}" Width="20"/>
 512:                                 </Grid>
 513:                                 <Button x:Name="HorizontalZoomOutButton" Grid.Column="1" HorizontalAlignment="Center" Height="20" Style="{StaticResource ZoomOut}" VerticalAlignment="Center" Width="20"/>
 514:                                 <!--Slider x:Name="HorizontalZoomRange" Grid.Column="4" HorizontalAlignment="Stretch" MinWidth="80" Orientation="Horizontal" VerticalAlignment="Center"/-->
 515:                                 <ProgressBar HorizontalAlignment="Left" Grid.Column="5" Visibility="Visible" Margin="0,20,0,20"  Foreground="Red" x:Name="HorizontalZoomRange" Width="100" Background="{StaticResource ZoomPaneSliderOuterBevelTopFill}"/>
 516:                                 <Button x:Name="HorizontalZoomInButton" Grid.Column="2" HorizontalAlignment="Center" Height="20" Style="{StaticResource ZoomIn}" VerticalAlignment="Center" Width="20"/>
 517:                                 <Button x:Name="HorizontalBackButton"  Grid.Column="3" Content="Back" Width="40" Margin="0,20,0,20" HorizontalAlignment="Right" d:LayoutOverrides="Width"/>
 518:                             </Grid>
 519:                             <Grid x:Name="VerticalRoot">
 520:                                 <Grid.RowDefinitions>
 521:                                     <RowDefinition Height="Auto"/>
 522:                                     <RowDefinition Height="*"/>
 523:                                 </Grid.RowDefinitions>
 524:                                 <Grid x:Name="ZoomControl" Grid.Column="0" Margin="0,-3,0,0" Grid.Row="1" Width="42">
 525:                                     <Grid.RowDefinitions>
 526:                                         <RowDefinition Height="32"/>
 527:                                         <RowDefinition Height="*"/>
 528:                                         <RowDefinition Height="32"/>
 529:                                     </Grid.RowDefinitions>
 530:                                     <Border x:Name="StrokeAndCenter" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,1" Background="{TemplateBinding Background}" CornerRadius="0,0,21,21" Margin="0,-7,0,0" Grid.Row="0" Grid.RowSpan="3"/>
 531:                                     <Border x:Name="HighlightStroke" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="0,0,20,20" Margin="1,-5,1,1" Grid.RowSpan="3"/>
 532:                                     <Border x:Name="SliderBvlTop" Background="{StaticResource ZoomPaneSliderOuterBevelTopFill}" CornerRadius="14,14,0,0" Margin="6,6,6,0" Grid.RowSpan="1"/>
 533:                                     <Border x:Name="SliderBvlMid" CornerRadius="0,0,0,0" Height="Auto" Margin="6,0,6,0" Grid.Row="1" Grid.RowSpan="1">
 534:                                         <Border.Background>
 535:                                             <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
 536:                                                 <GradientStop Color="#FFD3D9DE" Offset="0"/>
 537:                                                 <GradientStop Color="#FFFFFFFF" Offset="1"/>
 538:                                             </LinearGradientBrush>
 539:                                         </Border.Background>
 540:                                     </Border>
 541:                                     <Border x:Name="SliderBvlBtm" Background="{StaticResource ZoomPaneSliderOuterBevelBottomFill}" Grid.Column="0" CornerRadius="0,0,14,14" Margin="6,0,6,6" Grid.Row="2" Grid.RowSpan="1"/>
 542:                                     <Border x:Name="SliderStroke" Background="{StaticResource ZoomPaneSliderBorderFill}" CornerRadius="13,13,13,13" Margin="8,8,8,8" Grid.RowSpan="3"/>
 543:                                     <Border x:Name="SliderOverlay" Background="{StaticResource ZoomPaneSliderOverlayFill}" CornerRadius="12,12,12,12" Margin="9,9,9,9" Grid.RowSpan="3"/>
 544:                                     <Rectangle Fill="{StaticResource SliderTrackBackgroundFill}" Margin="10,0,10,0" Grid.Row="1" Grid.RowSpan="1"/>
 545:                                     <Slider x:Name="VerticalZoomRange" BorderBrush="#FFFFFFFF" HorizontalAlignment="Center" Margin="0,3,0,3" MinHeight="50" Orientation="Vertical" Grid.Row="1" Style="{StaticResource ZoomRange}" VerticalAlignment="Stretch"/>
 546:                                     <Grid x:Name="ZoomIn">
 547:                                         <Border BorderBrush="{StaticResource ZoomBtnBorderFill}" BorderThickness="0,0,0,1" Background="{StaticResource ZoomBtnCenterFill}" CornerRadius="11,11,0,0" Margin="10,10,10,1"/>
 548:                                         <Rectangle Fill="#FFFFFFFF" Height="1" Margin="10,0,10,0" VerticalAlignment="Bottom"/>
 549:                                         <Button x:Name="VerticalZoomInButton" Content="+" FontWeight="Normal" FontFamily="Arial" HorizontalAlignment="Stretch" Margin="10,10,10,0" Style="{StaticResource ZoomIn}" ToolTipService.ToolTip="{Binding ZoomIn, Source={StaticResource SR}}" VerticalAlignment="Stretch"/>
 550:                                     </Grid>
 551:                                     <Grid x:Name="ZoomOut" Grid.Row="2">
 552:                                         <Border BorderBrush="{StaticResource ZoomBtnBorderFill}" BorderThickness="0,1,0,0" Background="{StaticResource ZoomBtnCenterFill}" CornerRadius="0,0,11,11" Margin="10,0,10,10"/>
 553:                                         <Rectangle Fill="#FFFFFFFF" Height="1" Margin="10,1,10,0" VerticalAlignment="Top"/>
 554:                                         <Button x:Name="VerticalZoomOutButton" Content="-" FontWeight="Normal" FontFamily="Arial" HorizontalAlignment="Stretch" Margin="10,0,10,10" RenderTransformOrigin="0.5,0.5" Style="{StaticResource ZoomOut}" ToolTipService.ToolTip="{Binding ZoomOut, Source={StaticResource SR}}" VerticalAlignment="Stretch"/>
 555:                                     </Grid>
 556:                                 </Grid>
 557:                                 <Grid x:Name="PanControl" HorizontalAlignment="Center" Height="Auto" VerticalAlignment="Center" d:LayoutOverrides="Width, Height">
 558:                                     <Grid.ColumnDefinitions>
 559:                                         <ColumnDefinition Width="Auto"/>
 560:                                         <ColumnDefinition Width="Auto"/>
 561:                                         <ColumnDefinition Width="Auto"/>
 562:                                     </Grid.ColumnDefinitions>
 563:                                     <Grid.RowDefinitions>
 564:                                         <RowDefinition Height="Auto"/>
 565:                                         <RowDefinition Height="Auto"/>
 566:                                         <RowDefinition Height="Auto"/>
 567:                                     </Grid.RowDefinitions>
 568:                                     <Ellipse x:Name="BaseBg" Grid.ColumnSpan="3" Fill="{TemplateBinding Background}" Margin="0,0,0,0" Grid.RowSpan="3" Stroke="{TemplateBinding BorderBrush}"/>
 569:                                     <Ellipse x:Name="BaseInnerBorder" Grid.ColumnSpan="3" Margin="1,1,1,1" Grid.RowSpan="3" Stroke="{StaticResource PanPaneInnerBorderFill}"/>
 570:                                     <Ellipse x:Name="CenterCircle" Grid.ColumnSpan="3" Fill="{StaticResource BaseBgDarkInnerBorder}" Margin="10,10,10,10" Grid.RowSpan="3" Stroke="{StaticResource BaseBgCenterCircleLightBorderFill}"/>
 571:                                     <Ellipse x:Name="CenterCircleBg" Grid.ColumnSpan="3" Fill="{StaticResource BaseBgCenterCircleBackgroundFill}" Margin="12,12,12,12" Grid.RowSpan="3"/>
 572:                                     <Ellipse x:Name="CenterCircleBgOverlay" Grid.ColumnSpan="3" Fill="{StaticResource BasebgCenterCircleOverlay}" Margin="12,12,12,12" Grid.RowSpan="3"/>
 573:                                     <Button x:Name="VerticalPanNorthButton" Content="N" Grid.Column="1" HorizontalAlignment="Center" Margin="0,19,0,3" Style="{StaticResource Arrow}" ToolTipService.ToolTip="{Binding PanNorth, Source={StaticResource SR}}" VerticalAlignment="Center"/>
 574:                                     <Button x:Name="VerticalPanWestButton" Content="W" HorizontalAlignment="Center" Margin="17,0,3,0" Grid.Row="1" RenderTransformOrigin="0.5,0.5" Style="{StaticResource Arrow}" ToolTipService.ToolTip="{Binding PanWest, Source={StaticResource SR}}" VerticalAlignment="Center">
 575:                                         <Button.RenderTransform>
 576:                                             <TransformGroup>
 577:                                                 <ScaleTransform/>
 578:                                                 <SkewTransform/>
 579:                                                 <RotateTransform Angle="-90"/>
 580:                                                 <TranslateTransform/>
 581:                                             </TransformGroup>
 582:                                         </Button.RenderTransform>
 583:                                     </Button>
 584:                                     <Button x:Name="VerticalPanEastButton" Content="E" Grid.Column="2" HorizontalAlignment="Center" Margin="3,0,17,0" Grid.Row="1" RenderTransformOrigin="0.5,0.5" Style="{StaticResource Arrow}" ToolTipService.ToolTip="{Binding PanEast, Source={StaticResource SR}}" VerticalAlignment="Center">
 585:                                         <Button.RenderTransform>
 586:                                             <TransformGroup>
 587:                                                 <ScaleTransform/>
 588:                                                 <SkewTransform/>
 589:                                                 <RotateTransform Angle="90"/>
 590:                                                 <TranslateTransform/>
 591:                                             </TransformGroup>
 592:                                         </Button.RenderTransform>
 593:                                     </Button>
 594:                                     <Button x:Name="VerticalPanSouthButton" Content="S" Grid.Column="1" HorizontalAlignment="Center" Margin="0,3,0,19" Grid.Row="2" RenderTransformOrigin="0.5,0.5" Style="{StaticResource Arrow}" ToolTipService.ToolTip="{Binding PanSouth, Source={StaticResource SR}}" VerticalAlignment="Center">
 595:                                         <Button.RenderTransform>
 596:                                             <TransformGroup>
 597:                                                 <ScaleTransform ScaleY="-1"/>
 598:                                                 <SkewTransform/>
 599:                                                 <RotateTransform/>
 600:                                                 <TranslateTransform/>
 601:                                             </TransformGroup>
 602:                                         </Button.RenderTransform>
 603:                                     </Button>
 604:                                     <Button x:Name="VerticalFitButton" Content="*" Grid.Column="1" HorizontalAlignment="Stretch" Height="22" Margin="5,8,5,8" Grid.Row="1" Style="{StaticResource FitBtn}" ToolTipService.ToolTip="{Binding FitWindow, Source={StaticResource SR}}" Visibility="Visible" VerticalAlignment="Stretch" Width="22"/>
 605:                                 </Grid>
 606:                             </Grid>
 607:                         </Grid>
 608:                     </ControlTemplate>
 609:                 </Setter.Value>
 610:             </Setter>
 611:         </Style>
 612:     </UserControl.Resources>
 613:     <Grid x:Name="LayoutRoot" Background="White">
 614:         <ig:XamMap x:Name="xamMapCtrt"  d:LayoutOverrides="Width, Height" >
 615:             <ig:XamMap.Layers>
 616:                 <ig:MapLayer 
 617:                     x:Name="World" Brushes="#4C2C42C0 #4C218B93 #4CDC1C1C #4C3D7835 #4C701B51" 
 618:                     FillMode="Choropleth" Imported="World_Imported">
 619:                     <ig:MapLayer.Reader>
 620:                         <ig:ShapeFileReader Uri="ShapeFiles\Cntry00\Cntry00" 
 621:                             DataMapping="Name=CNTRY_NAME; Value=POP_CNTRY; Caption=CNTRY_NAME; ToolTip=CNTRY_NAME" />
 622:                     </ig:MapLayer.Reader>
 623:                     <ig:MapLayer.ValueScale>
 624:                         <ig:LinearScale IsAutoRange="True"/>
 625:                     </ig:MapLayer.ValueScale>
 626:                 </ig:MapLayer>
 627:             </ig:XamMap.Layers>
 628:             <ig:MapNavigationPane x:Name="navPane"  Margin="0" 
 629:                 HorizontalAlignment="Center" VerticalAlignment="Bottom" Orientation="Horizontal" Style="{StaticResource MapNavigationPaneCustomStyle}"/>
 630:         </ig:XamMap>
 631:     </Grid>
 632: </UserControl>

 

Create a new DependencyProperty named SelectedItemName and add code to highlight a selected MapElement.

   1: #region Properties
   2: #region SelectedItemName
   3:  
   4: /// <summary>
   5: /// SelectedItemName Dependency Property
   6: /// </summary>
   7: public static readonly DependencyProperty SelectedItemNameProperty =
   8:     DependencyProperty.Register("SelectedItemName", typeof(string), typeof(XamMapControl),
   9:         new PropertyMetadata("",
  10:             new PropertyChangedCallback(OnSelectedItemNameChanged)));
  11:  
  12: /// <summary>
  13: /// Gets or sets the SelectedItemName property. This dependency property 
  14: /// indicates ....
  15: /// </summary>
  16: public string SelectedItemName
  17: {
  18:     get { return (string)GetValue(SelectedItemNameProperty); }
  19:     set { SetValue(SelectedItemNameProperty, value); }
  20: }
  21:  
  22: /// <summary>
  23: /// Handles changes to the SelectedItemName property.
  24: /// </summary>
  25: private static void OnSelectedItemNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  26: {
  27:     XamMapControl target = (XamMapControl)d;
  28:     string oldSelectedItemName = (string)e.OldValue;
  29:     string newSelectedItemName = target.SelectedItemName;
  30:     target.OnSelectedItemNameChanged(oldSelectedItemName, newSelectedItemName);
  31: }
  32:  
  33: /// <summary>
  34: /// Provides derived classes an opportunity to handle changes to the SelectedItemName property.
  35: /// </summary>
  36: protected virtual void OnSelectedItemNameChanged(string oldSelectedItemName, string newSelectedItemName)
  37: {
  38:     if (!newSelectedItemName.Equals(oldSelectedItemName))
  39:     {
  40:         RestoreMapLayerSettings();
  41:         InitMap(newSelectedItemName);
  42:     }
  43:  
  44: }
  45:  
  46: #endregion //SelectedItemName
  47: #endregion //Properties
  48:  
  49: #region Methods
  50: #region InitMap
  51: private void InitMap(string newSelectedItemName)
  52: {
  53:     MapLayer world = this.xamMapCtrt.Layers["World"];
  54:  
  55:     foreach (MapElement el in world.Elements)
  56:     {
  57:  
  58:         if (el.Name.Equals(newSelectedItemName))
  59:         {
  60:             el.Fill = new SolidColorBrush(Colors.Red);
  61:             this.xamMapCtrt.WindowRect = el.WorldRect;
  62:         }
  63:     }
  64: }
  65: #endregion //InitMap
  66:  
  67: #region RestoreMapLayerSettings
  68: private void RestoreMapLayerSettings()
  69: {
  70:     MapLayer layer = this.xamMapCtrt.Layers["World"];
  71:     layer.DataSource = null;
  72:  
  73:     layer.DataMapping = null;
  74:  
  75:     layer.Reader.ImportAsync(layer);
  76:  
  77:     xamMapCtrt.ZoomIn();
  78:     xamMapCtrt.WindowFit();
  79: }
  80: #endregion //RestoreMapLayerSettings 
  81: #endregion //Methods
  82:  
  83: #region EventgHandlers
  84: #region World_Imported
  85: private void World_Imported(object sender, MapLayerImportEventArgs e)
  86: {
  87:     InitMap(this.SelectedItemName);
  88: }
  89: #endregion //World_Imported 
  90: #endregion //EventgHandlers

 

Add a new Silverlight User Control to the project, named LightSwitchMap.

This  control will contain code for binding to specific properties from the screen DataContext.

Edit a LightSwitchMap.xaml file:

   1: <UserControl x:Class="XamMapLibrary.LightSwitchMap"
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   5:     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   6:     xmlns:local="clr-namespace:XamMapLibrary"
   7:     mc:Ignorable="d"
   8:     d:DesignHeight="300" d:DesignWidth="400">
   9:     
  10:     <Grid x:Name="LayoutRoot" Background="White">
  11:         <local:XamMapControl SelectedItemName="{Binding Screen.IGCustomersCollection.SelectedItem.Country}"/>
  12:     </Grid>
  13: </UserControl>

 

Edit the screen IGCustomersListDetail.

From menu select: Add Layout Item –> Custom Control.

Add a reference to XamMapLibrary.  From XamMapLibrary
select LightSwitchMap control.

Custom control with a name ScreenContent is added in the IGCustomersListDetail screen.
Leave all properties with a default values.

Open the default startup folder  %Projects Folder%\InfraOrdersCustom\InfraOrders\Bin\Debug\Web
and add there a folder ShapeFiles with files, used as a data source
from XamMap control

Run the application

Select from the navigation pane: Customers Detail List

Detail list for the customers contains a map with a country of the customer in the detail part
of the screen.

Select a different customer.

In the detail part is displayed the country of the selected customer.

Conclusion:

Visual Studio LightSwitch custom Silverlight controls proposes a quick way to
extend LightSwitch application. It is very easy to use existing Silverlight controls in the
LightSwitch custom controls.

Source code of the demo application you could download here: