private void HandleTagCollectionChanges(object sender, NotifyDictionaryChangedEventArgs <string, TagPageSet> e) { Action a = null; switch (e.Action) { case NotifyDictionaryChangedAction.Add: a = () => Tags.AddAll(from i in e.Items select new TagSelectorModel(i, OnModelPropertyChanged));; break; case NotifyDictionaryChangedAction.Remove: a = () => Tags.RemoveAll(from i in e.Items select i.Key); break; case NotifyDictionaryChangedAction.Reset: a = () => Tags.Clear(); break; } if (a != null) { Dispatcher.Invoke(new Action(() => { a(); fireNotifyPropertyChanged(TAG_COUNT); })); } }