private void AddNote() { var addNoteViewModel = new AddEditNoteViewModel { IsGroupPossible = SelectedStage is StageObject }; addNoteViewModel.OnSaveAction = () => { ReactiveList <NoteObject> noteList = null; if (SelectedStage is StageObject) { if (addNoteViewModel.IsGroup) { var group = new InnerGroupObject { Name = addNoteViewModel.Name, IsSelected = true }; (SelectedStage as StageObject).InnerGroups.Add(group); SaveNote(); return; } noteList = (SelectedStage as StageObject).Notes; } else if (SelectedStage is InnerGroupObject) { noteList = (SelectedStage as InnerGroupObject).Notes; } else { foreach (var stage in stages) { if (stage.Notes.Contains(SelectedStage)) { noteList = stage.Notes; break; } foreach (var group in stage.InnerGroups) { if (group.Notes.Contains(SelectedStage)) { noteList = group.Notes; break; } } } } if (noteList == null) { return; } var note = new NoteObject { ID = ObjectsHelper.GetNextID(NoteService.CurrentNotesAppSettings.AllNotes), ParentStageType = NoteStageType, Name = addNoteViewModel.Name, DisplayedNote = addNoteViewModel.Name, IsSelected = true }; note.TrackChanges(true); noteList.Add(note); SaveNote(); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_AddEditNoteView_AddTitle"), Content = new AddEditNoteView(addNoteViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }