private void onCollectionCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Contract.Requires(sender is ObservableCollection <T>); Contract.Requires(this.collections.Contains(sender)); Contract.Requires(e != null); switch (e.Action) { case NotifyCollectionChangedAction.Add: this.Count += e.NewItems.Count; break; case NotifyCollectionChangedAction.Remove: this.Count -= e.OldItems.Count; break; case NotifyCollectionChangedAction.Replace: this.Count += e.NewItems.Count - e.NewItems.Count; break; case NotifyCollectionChangedAction.Move: break; case NotifyCollectionChangedAction.Reset: recomputeCount(); // I don't think one can reason what the new count is going to be in this case. Just recomputing is the only solution break; default: throw new DefaultSwitchCaseUnreachableException(); } int startIndexOfSender = computeStartingIndex((ObservableCollection <T>)sender); OnCollectionChanged(e.Shift(startIndexOfSender)); }