private void CSVLoad(string path) { using (var ReadStream = new StreamReader(path)) { while (!ReadStream.EndOfStream) { var Split = ReadStream.ReadLine().Split(';'); var NewBook = new Book() { ID = DGItemsSource.Count, Author = Split[0], Title = Split[1], Year = int.Parse(Split[2]) }; DGItemsSource.Add(NewBook); YearCombo.Add(int.Parse(Split[2])); } ReadStream.Close(); } YearCombo = new ObservableCollection <int>(YearCombo.Distinct()); }
public void AddBook(string Author, string Title, int Year) { DGItemsSource.Add(new Book { ID = 0, Author = Author, Title = Title, Year = Year }); }