Ну, я никогда не добавлял элементы на карту программно, но я считаю, что вы просто добавляете их на карты Children
. Я пытаюсь придерживаться шаблона MVVM, поэтому я полагаюсь на привязки и базовую модель просмотра, чтобы обновить карту соответствующим образом. Вот пример XAML из одного из моих проектов - я думаю, это поможет вам двигаться в правильном направлении:
<bingControl:Map x:Name="DirectionsMap"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AnimationLevel="Full"
Background="{StaticResource MapBackgroundBrush}"
CredentialsProvider="<YourCredentialsHere>"
ScaleVisibility="Collapsed"
ZoomLevel="5">
<bingControl:Pushpin x:Name="StartPushin"
Width="Auto"
Height="Auto"
Panel.ZIndex="50"
Content="{Binding StartAddress.Name}"
Location="{Binding StartAddress.Location}"
Style="{StaticResource DirectionsEndpointPushpinStyle}" />
<bingControl:Pushpin x:Name="DestinationPushpin"
Width="Auto"
Height="Auto"
Panel.ZIndex="50"
Content="{Binding DestinationAddress.Name}"
Location="{Binding DestinationAddress.Location}"
Style="{StaticResource DirectionsEndpointPushpinStyle}" />
<bingControl:MapItemsControl x:Name="DirectionsEdges"
Panel.ZIndex="10"
ItemsSource="{Binding DirectionsResult.RoutePath}">
<bingControl:MapItemsControl.ItemTemplate>
<DataTemplate>
<bingControl:MapPolyline Panel.ZIndex="20"
Locations="{Binding ''}"
Stroke="#5968F7"
StrokeThickness="4" />
</DataTemplate>
</bingControl:MapItemsControl.ItemTemplate>
</bingControl:MapItemsControl>
</bingControl:Map>