private void AddCar(object sender, RoutedEventArgs e) { decimal.TryParse(CarPrice.Text, out decimal price); string name = CarName.Text; if (CarEngine.SelectedIndex >= 0 && CarGearbox.SelectedIndex >= 0 && CarInterior.SelectedIndex >= 0 && CarExterior.SelectedIndex >= 0 && price >= 0) { EngineUI engineUI = CarEngine.SelectedItem as EngineUI; GearboxUI gearboxUI = CarGearbox.SelectedItem as GearboxUI; InteriorUI interiorUI = CarInterior.SelectedItem as InteriorUI; ExteriorUI exteriorUI = CarExterior.SelectedItem as ExteriorUI; CarUI carUI = new CarUI() { Engine = engineUI, Exterior = exteriorUI, Gearbox = gearboxUI, Interior = interiorUI, Name = name, Price = price, Status = "Not Sold" }; Methods.AddCar(carUI); } }