private void Model_NoteAdded(NoteModel note) { var viewModel = new NoteViewModel(this, note); _notes.Add(viewModel); }
void Notes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems) { //add a corresponding note var viewModel = new NoteViewModel(this, item as NoteModel); _notes.Add(viewModel); } break; case NotifyCollectionChangedAction.Reset: _notes.Clear(); break; case NotifyCollectionChangedAction.Remove: foreach (var item in e.OldItems) { _notes.Remove(_notes.First(x => x.Model == item)); } break; } }