public void Filter(IPredicate <Task> filter) { bool visible = filter.Filter(this); if (visible != _visible) { _visible = visible; RaisePropertyChanged("IsVisible"); } }
/// <summary> /// Sets the predicate to use to filter the items contained in this DataList. /// </summary> /// <param name="predicate">The predicate to use; null if no filter is to be applied.</param> public void UpdateFilter(IPredicate<object> predicate) { if ((_predicate == null) && (predicate == null)) { return; } UpdateVersion(); if (_snapShot == null) { RaisePropertyChanged("Count"); RaiseCollectionReset(); } else { object currentItem = null; if (IsCurrencyEnabled) { currentItem = CurrentItem; } // Potentially some items in the view are no longer in the snapshot and some new items // now become part of the snapshot. First we'll remove any that no longer should be in // the snapshot, and then we'll add whatever is. if (predicate != null) { for (int i = _snapShot.Count - 1; i >= 0; i--) { object item = _snapShot[i]; if (predicate.Filter(item) == false) { RemoveItem(item, i, /* raisePropertyChange */ false); } } } if (_predicate != null) { foreach (object item in _sourceData) { if ((_predicate.Filter(item) == false) && ((predicate == null) || predicate.Filter(item))) { AddItem(item, /* raisePropertyChange */ false); } } } if (currentItem != null) { bool currentItemChanged = false; int index = _snapShot.IndexOf(currentItem); if (index == -1) { index = 0; } CurrentIndex = index; RaisePropertyChanged("CanMovePrevious"); RaisePropertyChanged("CanMoveNext"); if (currentItemChanged) { RaisePropertyChanged("CurrentItem"); } } } _predicate = predicate; RaisePropertyChanged("Count"); }
public void Filter(IPredicate<Task> filter) { bool visible = filter.Filter(this); if (visible != _visible) { _visible = visible; RaisePropertyChanged("IsVisible"); } }
/// <summary> /// Sets the predicate to use to filter the items contained in this DataList. /// </summary> /// <param name="predicate">The predicate to use; null if no filter is to be applied.</param> public void UpdateFilter(IPredicate <object> predicate) { if ((_predicate == null) && (predicate == null)) { return; } UpdateVersion(); if (_snapShot == null) { RaisePropertyChanged("Count"); RaiseCollectionReset(); } else { object currentItem = null; if (IsCurrencyEnabled) { currentItem = CurrentItem; } // Potentially some items in the view are no longer in the snapshot and some new items // now become part of the snapshot. First we'll remove any that no longer should be in // the snapshot, and then we'll add whatever is. if (predicate != null) { for (int i = _snapShot.Count - 1; i >= 0; i--) { object item = _snapShot[i]; if (predicate.Filter(item) == false) { RemoveItem(item, i, /* raisePropertyChange */ false); } } } if (_predicate != null) { foreach (object item in _sourceData) { if ((_predicate.Filter(item) == false) && ((predicate == null) || predicate.Filter(item))) { AddItem(item, /* raisePropertyChange */ false); } } } if (currentItem != null) { bool currentItemChanged = false; int index = _snapShot.IndexOf(currentItem); if (index == -1) { index = 0; } CurrentIndex = index; RaisePropertyChanged("CanMovePrevious"); RaisePropertyChanged("CanMoveNext"); if (currentItemChanged) { RaisePropertyChanged("CurrentItem"); } } } _predicate = predicate; RaisePropertyChanged("Count"); }