private async void SelectedLocations_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { try { SelectedLocations.CollectionChanged -= SelectedLocations_CollectionChanged; if (e.NewItems != null) { foreach (Location newItem in e.NewItems) { SelectedLocations.Add(newItem); await _settingsService.AddLocationAsync(newItem); } } if (e.OldItems != null) { foreach (Location oldtem in e.OldItems) { SelectedLocations.Remove(oldtem); await _settingsService.RemoveLocationAsync(oldtem); } } SelectedLocations.CollectionChanged += SelectedLocations_CollectionChanged; } catch (Exception exeption) { _loggingService?.WriteError(exeption); } }
private void OnNotSelectedLocationDoubleClickCommand() { var location = SelectedNotSelectedLocation; if (location == null) { return; } NotSelectedLocations.Remove(location); SelectedLocations.Add(location); RaisePropertyChanged(() => SelectedLocations); RaisePropertyChanged(() => NotSelectedLocations); }
private void InitializeLocations() { SelectedLocations.CollectionChanged -= SelectedLocations_CollectionChanged; SelectedLocations.Clear(); foreach (var location in User.Locations) { if (_settingsService.Settings.Locations.Any(l => l.Id == location.Id)) { SelectedLocations.Add(location); } } SelectedLocations.CollectionChanged += SelectedLocations_CollectionChanged; }