Within a UWP-App (Windows 10) I've got a MapControl
and I'm using MapItemsControl
to deliver an overlay for that map. The ItemsSource
of that MapItemsControl
(which is an ObservableCollection
) is bound via xaml, but is only working in one direction:
Adding items to that collection is working fine and those items are shown in that MapControl
too.
Removing items to that collection is working too, but seemingly only within that collection - the visual representation on my MapControl
does not react to removing elements. This can lead to infinite adding of items into that map, while no item gets ever removed.
The ObservableCollection
gets updated quiet frequentely (via MapControl.ZoomLevelChanged-Event
) and gets cleared & repopulated in that process - might that be a problem?
Binding via xaml looks like this:
<maps:MapControl
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
[...]>
<maps:MapItemsControl ItemsSource="{x:Bind Path=MapDirectionOverlay, Mode=OneWay}"/>
</maps:MapControl>
Any suggestions?
Since using Clear-Method did not do the trick, I tried using other remove-methods of the
ObservableCollection
and eventually that worked.So in the end, this is the workaround I'm using:
After all I still don't get, why a simple
Clear
would not work, since it still should raise aNotifyCollectionChangedAction
. (Correct me if I'm wrong)