Accessing the Control Using a Bing Maps Key

 

To access the Bing Maps WPF Control and the functionality it provides, you need a Bing Maps Key, which you can get from the Bing Maps Account Center. Information about creating a Bing Maps account and getting a Bing Maps Key is found in the Getting a Bing Maps Key topic.

Note

You will see an error message on the map if you do not use a valid Bing Maps Key in your Bing Maps WPF Control application.

Use the Bing Maps Key in Your Application

After you have created a Bing Maps account, available Bing Maps Keys appear in the Bing Maps Dev Center. Click the Create or view Bing Maps keys link to view them. Copy the key associated with the Web site URL which corresponds to the application you are building and assign this string value to the ApplicationId property of an ApplicationIdCredentialsProvider object. Use this object to set the CredentialsProvider property. Or alternatively, you can just set the CredentialsProvider property of your map element in XAML as shown in the example below.

<Window x:Class="WPFTestApplication.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
    Width="1024" Height="768">
    <Grid>
        <m:Map x:Name="myMap" CredentialsProvider="INSERT_YOUR_BING_MAPS_KEY" Mode="Aerial"/>
    </Grid>
</Window>