private void MenuItemUpdate_Click(object sender, RoutedEventArgs e) { if (gViewCar.SelectedIndex != -1 && gViewCar.SelectedItems.Count == 1) { Car car = (Car)gViewCar.SelectedItem; CarDialog carDialog = new CarDialog("Update", car.MakeModel, car.EngineSize, car.Fuel); carDialog.Owner = this; carDialog.AssignResult += (make, size, fuel) => { car.MakeModel = make; car.EngineSize = size; car.Fuel = fuel; RefreshContent(); }; carDialog.ShowDialog(); } else { MessageBox.Show("Please select One car to update!"); } }
private void AddCar_Click(object sender, RoutedEventArgs e) { CarDialog carDialog = new CarDialog("Add", "", 1.8, ""); carDialog.AssignResult += (make, size, fuel) => { if (make != "") { Car newCar = new Car(make, size, fuel); cars.Add(newCar); } }; bool?result = carDialog.ShowDialog(); if (result == true) { RefreshContent(); } }