Have you tried the interactive SDK that Microsoft provides? It helped me out.
It seems that you need only place a MapLayer
and place Pushpin
controls in it. You use the MapLayer.Position
attached property to pin down anything within that map layer to the map; so that when the user moves the map it says. This attached property is of the type Location
which is a type that is proprietary to the Bing Map control that contains both a Longitude (double) and a Latitude (double) value. If you need to bind a collection of said locations than you can use a MapItemsControl
inside of a MapLayer
bind its ItemsSource
property to your collections. You can also create data template; just remember that your template root must use the MapLayer.Position
attached property to specify its location on the map. This can be bound to any Location
-typed value.
<UserControl x:Class="MapControlInteractiveSdk.Tutorials.DataBinding.TutorialMapItemsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:t="clr-namespace:MapControlInteractiveSdk.Tutorials.DataBinding"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
<UserControl.Resources>
<DataTemplate x:Key="LogoTemplate">
<!-- This doesn't have to be a pushpin control - it can be anything just apply
the "m:MapLayer.Position" property to whatever is the root of the
template.
-->
<m:Pushpin m:MapLayer.Position="{Binding Location}" />
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<m:Map CredentialsProvider="Your Key">
<m:MapLayer>
<m:MapItemsControl x:Name="ListOfItems"
ItemTemplate="{StaticResource LogoTemplate}"
ItemsSource="{Binding MyLocalizedEntities}">
</m:MapItemsControl>
</m:MapLayer>
<m:MapLayer>
<!-- You can have content in multiple layers: Latter layers are infront of former ones. -->
</m:MapLayer>
</m:Map>
</Grid>
</UserControl>