private void Submit(object sender, RoutedEventArgs e) { TreatmentSheetViewModel model = (TreatmentSheetViewModel)DataContext; if (model.Valid()) { DialogResult = true; } }
private void ButtoTreatmentSheetClick(object sender, RoutedEventArgs e) { TreatmentSheetViewModel model = new TreatmentSheetViewModel { Patient = mainModel.SelectedPatient }; TreatmentSheet window = new TreatmentSheet { DataContext = model }; window.ShowDialog(); if (window.DialogResult == true) { mainModel.SelectedPatient.TreatmentList.Add(model.NewTreatment); } }