Reputation: 425
I'm trying to bind my custom pushpin model to bing map control using MvvmLight toolkit. here is my code behind.
public class CustomPin
{
public int Id { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
}
public List<CustomPin> Pins = new List<CustomPin>();
private void BindLocation(List<Branch> branches)
{
for (int i = 0; i < branches.Count; i++)
{
CustomPin pin = new CustomPin();
pin.Id = i;
pin.Latitude = branches[i].Latitude;
pin.Longitude = branches[i].Longitude;
Pins.Add(pin);
}
}
And my XAML is :
<bm:Map x:Name="Mymap" ZoomLevel="1" Credentials="xxxxx" Width="1366" Height="362">
<bm:MapItemsControl x:Name="MapPins" ItemsSource="{Binding Pins}">
<bm:Pushpin>
<bm:MapLayer.Position>
<bm:Location Latitude="{Binding Path=Latitude}" Longitude="{Binding Path=Longitude}"></bm:Location>
</bm:MapLayer.Position>
</bm:Pushpin>
</bm:MapItemsControl>
</bm:Map>
I cant see my pushpins when i run this code.Where is wrong?
Upvotes: 0
Views: 436
Reputation: 8348
You are assigning the values to the list _Pins but you are binding it wrongly as Pins. So set your ItemSource as
ItemsSource="{Binding _Pins}"
Hope it helps.
Upvotes: 1