private void AddItem_Click(object sender, RoutedEventArgs e) { ShopItem shopItem = new ShopItem(); shopItem.Name = Iname.Text; Int32.TryParse(Icost.Text, out int price); shopItem.Price = price; shopItem.Description = Idescr.Text; if (Photo.FileName != string.Empty) { shopItem.Photo = Photo.FileName; } ShopItemsList.Add((ShopItem)shopItem); var results = new List <ValidationResult>(); var context = new ValidationContext(shopItem); string filename = @"F:\OOP\ShopItemList.xml"; XmlSerializeWrapper.Serialize(ShopItemsList, filename); MessageBox.Show("Информация добавлена в файл ShopItemList.xml"); }
//public int r; private void AddFuel_Click(object sender, RoutedEventArgs e) { Fuel fuel = new Fuel(); fuel.Name = Fname.Text; Int32.TryParse(Fcost.Text, out int price); fuel.Price = price; FuelList.Add(fuel); var results = new List <ValidationResult>(); var context = new ValidationContext(fuel); string filename = @"F:\OOP\FuelList.xml"; XmlSerializeWrapper.Serialize(FuelList, filename); MessageBox.Show("Информация добавлена в файл FuelList.xml"); }