private bool GetIsFiltering() { // Generally our hierarchy is at max 3 levels deep, this can be cached if we find it problematic SimpleCollectionView parent = this; while (parent != null) { if (parent.Options?.Filter != null) { return(true); } parent = parent.parent; } SimpleCollectionViewOptions childOptions = Options.ChildOptions; while (childOptions != null) { if (childOptions.Filter != null) { return(true); } childOptions = childOptions.ChildOptions; } return(false); }
private SimpleCollectionView(IEnumerable source, SimpleCollectionViewOptions options, SimpleCollectionView parent = null, string key = null, object item = null) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } this.wasFilterNull = (options.Filter == null); this.source = source; this.parent = parent; this.item = item; this.key = key; SetOptions(options, notify: false); var changed = source as INotifyCollectionChanged; if (changed != null) { changed.CollectionChanged += OnSourceCollectionChanged; } }
private void SetOptions(SimpleCollectionViewOptions newOptions, bool notify = true) { if (this.options != null) { this.options.PropertyChanged -= OnOptionsPropertyChanged; } this.options = newOptions; if (this.options != null) { this.options.PropertyChanged += OnOptionsPropertyChanged; } Reset(notify); }
public SimpleCollectionView(IEnumerable source, SimpleCollectionViewOptions options) : this(source, options, null, null) { }