private void Button_Click_2(object sender, RoutedEventArgs e) { List <Book> new_books = new List <Book>(); new_books = MyBookCollection.GetMyCollection(); Book bookToRemove = new_books.Single(b => b.Title == TitleTextBox.Text); new_books.Remove(bookToRemove); bookListBox.ItemsSource = new_books; }
public MainWindow() { InitializeComponent(); //listBoxBooksList.ItemsSource = MyBookCollection.GetMyCollection(); //ObservableCollection<Book> books = new ObservableCollection<Book>(); foreach (var book in MyBookCollection.GetMyCollection()) { books.Add(book); } this.DataContext = books; }
private void Button_Click(object sender, RoutedEventArgs e) { List <Book> new_books = new List <Book>(); new_books = MyBookCollection.GetMyCollection(); Book new_book = new Book(new_books.Last().Id + 1); new_book.Title = TitleTextBox.Text; new_book.Author = AuthorTextBox.Text; new_book.Year = Int32.Parse(YearTextBox.Text); new_book.IsRead = (bool)IsReadCheckBox.IsChecked; new_book.Format = (BookFormat)FormatComboBox.SelectedItem; bookListBox.ItemsSource = new_books; new_books.Add(new_book); bookListBox.ItemsSource = new_books; }
public MainWindow() { InitializeComponent(); bookListBox.ItemsSource = MyBookCollection.GetMyCollection(); FormatComboBox.ItemsSource = Enum.GetValues(typeof(BookFormat)).Cast <BookFormat>(); }