/// <summary> /// Synchronizes changes to the ApiViewModel's Results collection. The elements of that collection are assumed /// to implement IMappable (see the APIMASH_TomTom.TomTomCameraViewModel implementation for a sample reference). /// This code should require no changed regardless as long as the items in the Results collection implement IMappable. /// </summary> void Results_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { // only additions and wholesale reset of the ObservableCollection are currently supported switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems) { IMappable mapItem = (IMappable)item; PointOfInterestPin poiPin = new PointOfInterestPin(mapItem); poiPin.Tap += async(s, e2) => { TheMap.HighlightPointOfInterestPin(DefaultViewModel.SelectedItem, false); TheMap.HighlightPointOfInterestPin(poiPin.PointOfInterest, true); await ProcessSelectedItem(item); }; TheMap.AddPointOfInterestPin(poiPin, mapItem.Position); } break; case NotifyCollectionChangedAction.Reset: TheMap.ClearPointOfInterestPins(); break; // case NotifyCollectionChangedAction.Remove: // // TODO: (optional) if your application allows items to be selectively removed from the view model // code to remove a single associated push pin will be required. // // // // break; // not implemented in this context // case NotifyCollectionChangedAction.Replace: // case NotifyCollectionChangedAction.Move: } }