private void EditCarDialogClosingEventHandler(object sender, DialogClosingEventArgs e) { if ((e.Parameter as bool?) == true) { CarsControlViewModel vm = this.DataContext as CarsControlViewModel; CarViewModel carVM = e.Content as CarViewModel; if (carVM.Edit) { vm.UpdateCar(carVM); } else { vm.AddCar(carVM); } } }
private void AddCar_Click(object sender, RoutedEventArgs e) { CarViewModel vm = new CarViewModel(); DialogHost.Show(vm, "CarsDialogHost", EditCarDialogClosingEventHandler); }