Bing Maps Task

You’ve seen in previous Windows Phone Mini-tutorials STATUE of Libertythat all tasks have the same basic structure:

  • Instantiate the task
  • Add any specifying data
  • Show the task

The Bing Maps Task is no different. In fact, it is so simple to use I hesitate to dedicate a mini-tutorial to it.  This will be brief.

To find a specific location using Bing Maps, all you need do is create a new Windows Phone application.  Set the Page and Application title and create a new row into which you’ll place a button (all of this is optional, but it makes the program easier to work with). 

Name the new button FindSiteButton and give it an event handler on its click event, as shown here:

        Text="Bing Maps"
        Style="{StaticResource PhoneTextNormalStyle}" />
        Style="{StaticResource PhoneTextTitle1Style}" />

<!--ContentPanel - place additional content here-->
            Height="96*" />
            Height="511*" />
        Click="FindSiteButton_Click" />

Since you put the event handler into the Xaml, you’ll find a stub for that method in the code behind.  Switching to MainPage.xaml.cs, let’s fill in that event handler.

We do so by adding an instance of BingMapsTask (which you’ll need to add the using statement,

using Microsoft.Phone.Tasks;


Set the SearchTerm property of this task to a famous location and then, as with all tasks, call show:

private void FindSiteButton_Click( 
    object sender, RoutedEventArgs e )
    BingMapsTask bmt = new BingMapsTask();
    bmt.SearchTerm = "Statue of Liberty";


Now run the emulator, click the button and you will see that Bing Maps instantly displays a map with the Statue of Liberty pin-pointed.

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen Pluralsight & LinkedIn Learning courses. He was a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP and a Microsoft MVP.
This entry was posted in Essentials, Mango, Mini-Tutorial, Patterns & Skills, WindowsPhone and tagged . Bookmark the permalink.

4 Responses to Bing Maps Task

Comments are closed.