void OnLayersCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { AddLayers(e.NewItems.Cast <Layer>().ToList()); } else if (e.Action == NotifyCollectionChangedAction.Remove) { RemoveLayers(e.OldItems); } else if (e.Action == NotifyCollectionChangedAction.Reset) { var layers = map.Layers; foreach (var layer in layers) { if (layer.Id.HasPrefix()) { map.RemoveLayer(layer); } } } else if (e.Action == NotifyCollectionChangedAction.Replace) { RemoveLayers(e.OldItems); AddLayers(e.NewItems.Cast <Layer>().ToList()); } }