private void RefreshFilteredItems() { if (_collectionView == null) return; IFilterCommand filterCommand = GetMatchingFilterCommand(); if (filterCommand != null) { if (filterCommand != _activeFilterCommand) // Set the new filter command. { _activeFilterCommand = filterCommand; _collectionView.Filter = GetMatchStrategy(filterCommand); } } else if (_activeFilterCommand != null) // Remove the filter command and reset the filter strategy. { _activeFilterCommand = null; _collectionView.Filter = GetMatchStrategy(FilterStrategy); } var items = _collectionView.Cast<object>(); var itemsList = new List<object>(items); FilteredItems = itemsList; _filteredItemsPopup.IsOpen = itemsList.Count > 0; }
private Predicate<object> GetMatchStrategy(IFilterCommand filterCommand) { return o => { var text = _textBox.Text.Replace(filterCommand.CommandText, "").Trim(); return text.Length > 0 && filterCommand.IsMatch(o, text); }; }
public FilterRepository(IFilterCommand filterCommand, IFilterQuery filterQuery) { _filterCommand = filterCommand; _filterQuery = filterQuery; }