Silverlight Sample Application – Part 5

In this series blog post I’m completing this run about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

You can get the source to the application on CodePlex.

The purpose of the application (other than to show people how to get started with Silverlight application development), was to be an IT event information application.  The fourth ‘page’ of the application shows a map of the area indicating the location of the event.

Here it is showing the location of the Ottawa IT Day event.

20100613 map

This was done using the Bing Maps Silverlight control.

There are 4 key resource links for using this control.

To use the control you:

  • Install the SDK (which will place a couple of important DLLs in a folder you specify when installing)
  • Add a reference to the SDK DLLs to your project.
  • Add the MapControl namespace to your page XAML

20100613 map ns

  • Add the control to your XAML

20100613 map xaml 

  • Setup the control how you link in your code behind file

20100613 map code

The ApplicationId is obtained from the developer portal where you’ll need to agree to various licensing conditions.  With the Id the control will show a message indicated that it needs to be licensed.

A specific ZoomLevel is set in this example and the view is set to road mode.

The Location is set up from properties on the Application class and initialised elsewhere in this case.

The map is centred on the desired location and a Pushpin added there too.

A piece of control tree is created in code and this is added to the map and positioned at the desired location.  See the interactive SDK to learn how to add information to the map.

This control is extremely powerful and can be seem working live in the Silverlight page designer inside Visual Studio, e.g. set the ZoomLevel as an attribute on the XAML map element and you’ll see the map zoom in live!

Quite straight forward and you can (as with any XAML-related coding) chose for the most party whether to place settings in XAML or in code.

My only real issue with the control is the licensing for use of the control on intranets.

This concludes the posts on the sample application.

Check out other series blog posts for previously posted information about this sample application.