private void addBookOf(object sender, RoutedEventArgs e) { var b = NameBook.SelectedItem as Book; if (b != null) { var item = lv_DSTheLoai.SelectedItem as Genre; if (item != null) { if (!BooksOfSelectedGenre.Any(x => x.Name == b.Name)) { b.Tag = "New Link"; BooksOfSelectedGenre.Add(b); item.IsEditedItem = true; } } } }
private void removeLink(object sender, RoutedEventArgs e) { var control = sender as Button; var tag = control.Tag as Book; if (tag != null) { if (tag.Tag != null) { BooksOfSelectedGenre.Remove(tag); } else { tag.Switch = true; } var item = lv_DSTheLoai.SelectedItem as Genre; if (item != null) { item.IsEditedItem = true; } } }