public void FilterVeggies() { filter.FilterVeggies(); if (FilteredCollection != null) { FilteredCollection.Clear(); } foreach (var item in filter.productCatalogFilters) { FilteredCollection.Add(item); } }
/// <summary> /// method for filterCommand /// </summary> public void FilterExecute() { FilteredCollection.Clear(); switch (SelectedFilterItem) { case "System.Windows.Controls.ComboBoxItem: Titel": foreach (ViewComic viewComic in _comicList) { if (viewComic.Title.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } break; case "System.Windows.Controls.ComboBoxItem: Reeks": foreach (ViewComic viewComic in _comicList) { if (viewComic.Series.Name.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } break; case "System.Windows.Controls.ComboBoxItem: Auteur": foreach (ViewComic viewComic in _comicList) { foreach (ViewAuthor author in viewComic.Authors) { if (author.Name.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } } break; case "System.Windows.Controls.ComboBoxItem: Uitgeverij": foreach (ViewComic viewComic in _comicList) { if (viewComic.Publisher.Name.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } break; default: break; } }
private void RepopulateFilteredCollection() { List <BoardGameDataItem> filtered = new List <BoardGameDataItem>(); foreach (BoardGameDataItem ci in Collection) { bool ShowMe = true; if (CurrentPlayerFilter != null) { ShowMe = CurrentPlayerFilter.Matches(ci); } if (ShowMe && CurrentPlayTimeFilter != null) { ShowMe = CurrentPlayTimeFilter.Matches(ci); } if (ShowMe && CurrentStatusFilter != null) { ShowMe = CurrentStatusFilter.Matches(ci); } if (ShowMe && CurrentExpansionFilter != null) { ShowMe = CurrentExpansionFilter.Matches(ci); } if (ShowMe && CurrentTextFilter != null) { ShowMe = CurrentTextFilter.Matches(ci); } if (ShowMe) { filtered.Add(ci); } } IOrderedEnumerable <BoardGameDataItem> sortedList = CurrentCollectionSorter.Sort(filtered); FilteredCollection.Clear(); foreach (BoardGameDataItem item in sortedList) { FilteredCollection.Add(item); } RaisePropertyChanged("NumberItemsDisplayed"); }
private async void RunFilter() { _delay?.Cancel(); _delay = new CancellationTokenSource(); try { await Task.Delay(500, _delay.Token); } catch (TaskCanceledException) { // request was canceled, return; return; } var currentText = _searchBox?.Text ?? string.Empty; var sourceCollection = SourceCollection.Cast <FileContainer>().ToList(); if (string.IsNullOrWhiteSpace(currentText)) { // When nothing is being filtered, we dont need to filter any thing. FilteredCollection.Clear(); FilteredCollection.AddRange(sourceCollection, true); } else { // Remove any items in the filtered collection that are no longer available in the primary collection var oldItems = (from x in FilteredCollection where !sourceCollection.Contains(x) select x).ToList(); oldItems.ForEach(x => FilteredCollection.Remove(x)); // look at existing filtered items and remove those that do not match the filter oldItems = (from x in FilteredCollection where !DoesContainString(x, currentText) select x).ToList(); oldItems.ForEach(x => FilteredCollection.Remove(x)); // Look at the source colleciton and find out what needs to be in the filtered collection var newItems = (from x in sourceCollection where DoesContainString(x, currentText) && !FilteredCollection.Contains(x) select x).ToList(); FilteredCollection.AddRange(newItems, true); } }