Exemple #1
0
        private void OnItemSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (IBindingMapAnnotation item in e.NewItems)
                {
                    Target.AddAnnotation(new BindingMKAnnotation(item));
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (IBindingMapAnnotation item in e.OldItems)
                {
                    var oldItem = Target.Annotations.SingleOrDefault(x => (x is BindingMKAnnotation anno) && ReferenceEquals(anno.Annotation, item));
                    Target.RemoveAnnotation(oldItem);
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                Target.UpdatePins();
                break;

            case NotifyCollectionChangedAction.Replace:
                foreach (IBindingMapAnnotation item in e.OldItems)
                {
                    var oldItem = Target.Annotations.SingleOrDefault(x => (x is BindingMKAnnotation anno) && ReferenceEquals(anno.Annotation, item));
                    Target.RemoveAnnotation(oldItem);
                }
                foreach (IBindingMapAnnotation item in e.NewItems)
                {
                    Target.AddAnnotation(new BindingMKAnnotation(item));
                }
                break;

            default:
                Target.UpdatePins();
                break;
            }
        }
        private void OnItemSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (IBindingMapAnnotation item in e.NewItems)
                {
                    Target.AddAnnotation(item);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (IBindingMapAnnotation item in e.OldItems)
                {
                    Target.RemoveAnnotation(item);
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                Target.UpdateAnnotations();
                break;

            case NotifyCollectionChangedAction.Replace:
                foreach (IBindingMapAnnotation item in e.OldItems)
                {
                    Target.RemoveAnnotation(item);
                }
                foreach (IBindingMapAnnotation item in e.NewItems)
                {
                    Target.AddAnnotation(item);
                }
                break;

            default:
                Target.UpdateAnnotations();
                break;
            }
        }