Bing Maps - Auto update location binding of pushpins
Posted
by
abp
on Stack Overflow
See other posts from Stack Overflow
or by abp
Published on 2010-11-18T15:25:44Z
Indexed on
2011/01/16
20:53 UTC
Read the original article
Hit count: 211
Hi
I'm using the Bing Maps control to display a series of custom pushpins, representing objects which are constantly moving around and changing state.
Using databinding the various properties for the objects are being updated as they should, but for some reason this doesn't apply to their locations.
I have the map bound to an ObservableCollection as such:
<UserControl.Resources>
<DataTemplate x:Key="PushpinTemplate">
<v:CustomPushpin />
</DataTemplate>
</UserControl.Resources>
...
<m:Map Name="map">
<m:MapItemsControl ItemTemplate="{StaticResource PushpinTemplate}" ItemsSource="{Binding Objects}" />
</m:Map>
...and in CustomPushpin:
<UserControl
...
m:MapLayer.Position="{Binding Location}" m:MapLayer.PositionOrigin="BottomCenter"
mc:Ignorable="d" d:DesignHeight="126" d:DesignWidth="85">
Like all other properties, the Location of the individual objects are implemented using INotifyPropertyChanged.
private Location _location;
public Location Location
{
get { return _location; }
set { _location = value; OnPropertyChanged("Location"); }
}
When the map is moving, either because of panning or zooming, the objects move, but othersize not.
I can't quite figure if I'm doing something wrong here, or if it's a problem with the Bing Maps control.
Any thought?
© Stack Overflow or respective owner