This simple tutorial walks you through the process of creating a Visual Studio project for use with the Silverlight API. This project is a useful template for your own applications. This tutorial is one of many Telogis Silverlight API tutorials.

Adding a Client Access policy

Before most projects that use the Silverlight API can work, you must specify a client access policy that allows them to meet security constraints for internet access.  This process is described in the topic "Starting with Silverlight" in the Silverlight API documentation. If you have not already done so:

  • Copy the file clientaccesspolicy.xml to your Inetpub\wwwroot directory. In a default installation, you can find a sample clientaccesspolicy.xml in the Documents and Settings\All Users\Application Data\GeoBase Examples\SilverStream directory.

Creating a new project

Launch Visual Studio and select File | New Project...

Select a Silverlight project from the left-hand pane, and name the project appropriately. Click OK.

If prompted, select to host the new application in a web site.

Your Silverlight application may behave differently in a test page. It is good practise to develop your application in an environment that is as close to the deployment environment (typically a web site) as possible. For this reason it's recommended that you host the new application in a web site.


Add a reference to the Silverlight DLL

Right-click References in Solution Explorer and select Add Reference...

Select the Browse tab and locate Telogis.GeoBase.Silverlight.dll. Select the DLL and click OK.

Configuring a GeoStream Server

The Silverlight API obtains map and routing information from a GeoStream server. You should set the Telogis.GeoBase.Settings.ServerUrl property to the URL of a GeoStream server. If you don't do this your Silverlight application will be unable to display map data.

For the purpose of the quickstart guides it is sufficient to open App.xaml.cs and modify the Application_Startup method to match the code snippet below. It's assumed that you are running a GeoStream server on your local machine (GeoBase installed a GeoStream server by default). Otherwise, modify the server URL string as appropriate.

private void Application_Startup(object sender, StartupEventArgs e)
{
  Telogis.GeoBase.Settings.ServerUrl = "http://localhost/GeoStream";
  this.RootVisual = new MainPage();
}

Conclusion

Your project is now ready for Silverlight development! Typically, the next task would be to add the following attribute to your UserControl tag (in the MainPage.xaml source file). This attribute allows your XAML code to access the Telogis.GeoBase namespace.

xmlns:GeoBase="clr-namespace:Telogis.GeoBase;assembly=Telogis.GeoBase.Silverlight"

You are now ready to begin adding your own controls and supporting code.

Next steps

If you're new to Silverlight development we recommend you read the Creating a simple Silverlight map tutorial. This tutorial will show you how to add a map to your project.

This tutorial is one of many Telogis Silverlight API tutorials.

 

 

Published, Apr 6th 2011, 03:05

Tagged under: silverlight