Accessing the Control Using a Bing Maps Key
Note
Bing Maps WPF Control retirement
Bing Maps WPF Control is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps WPF Control until June 30th, 2025. Enterprise account customers can continue to use Bing Maps WPF Control until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps WPF Control will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type.
Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.
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="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://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>