private void Note_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { Note noteToUpdate = sender as Note; NoteEventArgs args = new NoteEventArgs(NoteChangedEvent, noteToUpdate); RaiseEvent(args); }
private void btnRemove_Click(object sender, RoutedEventArgs e) { if (lstNotes.SelectedIndex >= 0) { Note noteToRemove = lstNotes.SelectedItem as Note; Notes.Remove(noteToRemove); NoteEventArgs args = new NoteEventArgs(NoteRemovedEvent, noteToRemove); RaiseEvent(args); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { Note newNote = new Note { DateCreated = DateTime.Now.Subtract(TimeSpan.FromDays(1.0)), Data = string.Empty }; Notes.Add(newNote); foreach (INotifyPropertyChanged note in Notes) { note.PropertyChanged -= Note_PropertyChanged; note.PropertyChanged += Note_PropertyChanged; } lstNotes.SelectedIndex = lstNotes.Items.Count - 1; NoteEventArgs args = new NoteEventArgs(NoteAddedEvent, newNote); RaiseEvent(args); }