void EditExecute() { EditStudentWindow window = new EditStudentWindow(); Student editItem = new Student(); editItem.CloneFrom(this.SelectedItem); EditStudentWindowViewModel vm = new EditStudentWindowViewModel(editItem, window); window.DataContext = vm; window.ShowDialog(); OnEditComplete(vm); }
void OnEditComplete(EditStudentWindowViewModel vm) { if (vm.IsSaveClicked) { if (!vm.IsForNew) { this.SelectedItem.CloneFrom(vm.CurrentStudent); ((MainWindow)this.CurrentWindow).ResizeGridViewColumns(); } else { Student stu = vm.CurrentStudent; this._allStudents.Add(stu); DBHandler.Instance.Insert(stu); this.Students = this._allStudents; ((MainWindow)this.CurrentWindow).ResizeGridViewColumns(); } } }
void AddExecute() { EditStudentWindow window = new EditStudentWindow(); EditStudentWindowViewModel vm = new EditStudentWindowViewModel(null, window); window.DataContext = vm; window.ShowDialog(); OnEditComplete(vm); }