Reputation: 85
How to Bind location in bing maps( Longitude & Latitude ) ??
after created a maps i would like bind more than one location and i trying in this code but not work why ?
<bm:Map Height="350" Credentials="xxxxxxxxxxxx" x:Name="Map" ZoomLevel="16" Margin="-27,28,10,78">
<bm:Map.Center>
<bm:Location Latitude="{Binding Longitude}" Longitude="{Binding Latitude}"/>
</bm:Map.Center>
</bm:Map>
Upvotes: 2
Views: 3584
Reputation: 12465
You can bind a collection of items as such.
<Maps:Map x:Name="Map" CredentialsProvider="BlaaBlaaBlaa" ZoomLevel="16" Margin="-27,28,10,78">
<Maps:MapItemsControl ItemsSource="{Binding Locations}">
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate>
<Maps:Pushpin Location="{Binding Location}" Content="{Binding Name}"
Background="{StaticResource PhoneAccentBrush}">
</Maps:Pushpin>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
</Maps:Map>
In this example I have a property Locations
that is a collection of MapLocation
objects
// DataContext
public ObservableCollection<MapLocation> Locations { get; private set; }
And the MapLocation class
public class MapLocation
{
public GeoCoordinate Location { get; set; }
public string Name { get; set; }
}
Upvotes: 4