private void GetWines() { string fileName = ConfigurationManager.AppSettings["winefilelocation"]; XmlDocument document; try { document = new XmlDocument(); document.Load(fileName); wines.Clear(); countries.Clear(); countries.Add("Kaikki"); foreach (XmlNode node in document.DocumentElement.ChildNodes) { string points = node.SelectSingleNode("arvio").InnerText; int p = 0; Int32.TryParse(points, out p); Wine wine = new Wine(); wine.Name = node.SelectSingleNode("nimi").InnerText; wine.Country = node.SelectSingleNode("maa").InnerText; if (!countries.Contains(wine.Country)) { countries.Add(wine.Country); } wine.Points = p; wines.Add(wine); } this.dtGridWines.ItemsSource = null; this.cmbBoxSelectCountry.ItemsSource = countries; this.dtGridWines.ItemsSource = null; this.dtGridWines.ItemsSource = wines; this.Title = "WineViewer - " + fileName; this.ShowInStatusBar("Succesfully loaded " + fileName); } catch (Exception ex) { this.ShowInStatusBar("Error: Can't found the xml file."); } }
public NewWineCreator() { InitializeComponent(); this.wine = new Wine(); }