private void ApplySearchFilter() { var filteredDownloadEntries = _allDownloadEntries; if (!_showVisisitedDownloadEntries) { filteredDownloadEntries = filteredDownloadEntries.Where(f => !f.DownloadLinkIsVisited); } DownloadEntries = new ObservableCollection <DownloadEntryWithConfiguration>(filteredDownloadEntries); if (!_initialLoaded) { _initialLoaded = true; DownloadEntries = new ObservableCollection <DownloadEntryWithConfiguration>(filteredDownloadEntries); } else { Application.Current.Dispatcher.Invoke(() => { // UI looks smoother if we operate directly on the List var removedEntries = DownloadEntries.Where(p => filteredDownloadEntries.All(f => f != p)).ToList(); removedEntries.ForEach(f => DownloadEntries.Remove(f)); var addedEntries = filteredDownloadEntries.Where(p => DownloadEntries.All(f => f != p)).ToList(); addedEntries.ForEach(f => DownloadEntries.Add(f)); }); } }
private void DownloadEntry_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(DownloadEntryWithConfiguration.DownloadLinkIsVisited)) { var obj = (DownloadEntryWithConfiguration)sender; if (obj.DownloadLinkIsVisited && !_showVisisitedDownloadEntries) { DownloadEntries.Remove(obj); } } }