Bing Maps - snap bindings automatically update bindings

I use the Bing Maps control to display a series of custom buttons representing objects that constantly move and change state.

Using data binding of various properties for objects is updated as necessary, but for some reason this does not apply to their locations.

I have a map associated with 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 individual objects is implemented using the INotifyPropertyChanged method.

private Location _location;
public Location Location
{
   get { return _location; }
   set { _location = value; OnPropertyChanged("Location"); }
}

When the map moves, due to panning or zooming, objects move, while others do not.

I can’t understand that I’m doing something wrong, or if this is a problem with the Bing Maps control.

Any thought?

+3
6

, :

_pushPin.Location.Latitude = xyz...

:

_pushPin.Location = new Location(_location);

BingMap -

+2

map.SetView(map.BoundingRectangle); 

+1

. Pushpin :

_pushPin.Location = null;
_pushPin.Location = _location;

_pushPin.Location = new Location(_location);

, .

+1

Candritzky:

ItemsPanel , AttachedProperty. :)

+1

- : , Bing Map Control Microsoft . , .

0

, - , , ObjectCollection ObservableCollection<Object>. ObjectCollection.Refresh() :

public void Refresh()
{
    base.OnCollectionChanged(new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Reset));
}

, .

0

Source: https://habr.com/ru/post/1775668/


All Articles