As you mentioned, the Location
and Title
can bind to Geopoint
and AttractionName
. But to display MapIcon on the MapControl, we need to add MapIcon to its MapElements collection programmatically.
For example:
In the Loaded
event of the MapControl
.
private void MapControl_Loaded(object sender, RoutedEventArgs e)
{
MapControl.MapElements.Add(MyMapIcon);
}

After this the MapIcon
can show on the MapControl
like the image. But you will find there is a string of class name on the top left corner of MapControl
.
It is because you add the MapIcon
as implicit children of the MapControl. It is equivalent to add MapIcon
in MapItemsControl
like the following XAML code.
<Maps:MapControl x:Name="MapControl" ZoomLevel="14" Center="{Binding Geopoint, Mode=OneWay}" Margin="-12,0,-12,0" Height="200" PanInteractionMode="Disabled" RotateInteractionMode="Disabled" Loaded="MapControl_Loaded">
<Maps:MapItemsControl>
<Maps:MapIcon x:Name="MyMapIcon" Location="{Binding Geopoint}" Title="{Binding AttractionName}" />
</Maps:MapItemsControl>
</Maps:MapControl>
MapItemsControl can displays XAML user interface elements such as a Button, a HyperlinkButton, or a TextBlock by adding them as Children of the MapControl. The MapIcon can not show on the MapControl, so it show its class name.
As a workaround we can put MapIcon
in the Resources
to solove the problem.
For example:
<Page.Resources>
<Maps:MapIcon x:Name="MyMapIcon" Location="{Binding Geopoint}" Title="{Binding AttractionName}" />
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Maps:MapControl x:Name="MapControl" ZoomLevel="14" Center="{Binding Geopoint, Mode=OneWay}" Margin="-12,0,-12,0" Tapped="directions_Click" Height="200" MapServiceToken="{StaticResource BingMapsKey}" PanInteractionMode="Disabled" RotateInteractionMode="Disabled" Loaded="MapControl_Loaded">
</Maps:MapControl>
</Grid>