I have tried data binding an observable collection to an InformationLayer. But it seems it does not catch the ICollectionChange event. informationLayer.InvalidateArrange() needs to be called manually after the collection is altered.
ObservableCollection<Pushpin> _pins = new ObservableCollection<Pushpin>(); |
private void radMap_InitializeCompleted(object sender, EventArgs e) |
{ |
if (!this.isInitialized) |
{ |
isInitialized = true; |
// initializing draagable object |
Pushpin pushpin = new Pushpin(); |
ToolTip tooltip = new ToolTip(); |
tooltip.Content = "3 house st"; |
ToolTipService.SetToolTip(pushpin, tooltip); |
this.MakeFrameworkElementDraggable(pushpin); |
MapLayer.SetLocation(pushpin, new Location(37.747440943384, -95.2481111547551)); |
_pins.Add(pushpin); |
pushpin = new Pushpin(); |
this.MakeFrameworkElementDraggable(pushpin); |
MapLayer.SetLocation(pushpin, new Location(37.247440943384, -95.8481111547551)); |
_pins.Add(pushpin); |
informationLayer.ItemsSource = _pins; |
} |
} |
private void Button_Click(object sender, RoutedEventArgs e) |
{ |
Pushpin pushpin = new Pushpin(); |
ToolTip tooltip = new ToolTip(); |
tooltip.Content = "new pushpin"; |
ToolTipService.SetToolTip(pushpin, tooltip); |
this.MakeFrameworkElementDraggable(pushpin); |
MapLayer.SetLocation(pushpin, new Location(36.747440943384, -94.2481111547551)); |
_pins.Add(pushpin); |
informationLayer.InvalidateArrange(); |
} |