I wanted to start with a simple “Hello World!” sample to show you how to create your first application with the Virtual Earth Silverlight Map Control CTP. With just a few easy steps, you can get started building applications with the Virtual Earth Silverlight Map Control and get the rich interactive experience of Silverlight. Here are the steps to download the Virtual Earth Silverlight Map Control CTP and build your first application.
Download the Virtual Earth Silverlight Map Control CTP SDK from the Microsoft Connect Portal. If you have not registered with Microsoft Connect, you will be prompted to register with a Windows Live ID. Once you sign in, if this is your first visit to the Virtual Earth Silverlight Map Control CTP page, you will be asked a small set of survey questions to enroll in the CTP program. Once you are enrolled, you can click on the Downloads link on the left to download the SDK installer. Once you download the installer and run it, the Microsoft Virtual Earth Silverlight Map Control CTP SDK will be installed on your system. This includes the map control assembly and the SDK help file.
Now you are ready to create your first project. Make sure you have Visual Studio 2008 SP1 installed along with the Silverlight Tools for Visual Studio 2008 SP1. In Visual Studio, create a new Silverlight project by selecting File->New->Project
In the New Project window, select Silverlight Application and click OK
You will then be prompted to create a new web site in the project. Select “Add a new ASP.NET web project to the solution to host Silverlight” and click OK. This will allow you host and test your Virtual Earth application locally using HTTP since the Virtual Earth application makes HTTP requests to different domains to request tiles and web services.
Now that your project is created, you need to add a reference to the Virtual Earth Silverlight Map control assembly. To do this, right-click on References in the solution and select Add Reference and then browse for and select the Silverlight map control assembly that was installed with the SDK and click OK. The default installation path for the assembly is Program Files\Microsoft Virtual Earth Silverlight Map Control\CTP\Libraries\Microsoft.VirtualEarth.MapControl.dll.
Now, you just need to add a Map object to your Page.xaml file in your solution. Double click on the Page.xaml file in the solution and add the following 2 lines.
Add the MapControl namespace property to the UserControl element:
Then, add a Map object in the Grid of your User Control
Here is the complete listing of the Page.xaml code with the 2 lines added highlighted in bold:
<Grid x:Name=”LayoutRoot” Background=”White”>
Press CTRL-F5 to build your application and see your first Virtual Earth Silverlight Map Control application running locally:
You can see this sample running here:
So with 2 small lines of XAML, you are able to get the Virtual Earth Silverlight map up and running and get the rich interactive deep zoom experience of Silverlight!
(Note: this post is also available at the Virtual Earth Platform Team Blog)