public override void OnActivated() { base.OnActivated(); // CollectionModuleBase handles activation of common parts Series = state_manager.CurrentCollection.Series.Select(s => new SeriesViewModel(s)).ToObservableCollection(); SelectedSeries = Series.FirstOrDefault(); collection_subscription = state_manager.CurrentCollection.Series.SomethingChanged.Subscribe(_ => Update()); }
public override void OnDeactivated() { base.OnDeactivated(); // CollectionModuleBase handles deactivation of common parts collection_subscription.Dispose(); collection_subscription = null; Series.DisposeAll(); Series = null; SelectedSeries = null; }
private void Update() { var selected_series = SelectedSeries?.Obj; Series.DisposeAll(); Series = state_manager.CurrentCollection.Series.Select(s => new SeriesViewModel(s)).ToObservableCollection(); SelectedSeries = Series.FirstOrDefault(s => s.Metadata["GoodreadsSeriesId"] == selected_series?.Metadata["GoodreadsSeriesId"]); // If selected_series was null, we will end up here if (SelectedSeries == null) { SelectedSeries = Series.FirstOrDefault(); } }