//搜索框文本改变时,改变显示的建议 private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { suggestions.Clear(); ObservableCollection <string[]> books = BookDB.findBookFromStore(sender.Text); foreach (string[] book in books) { string title = (string)book[0]; string catalog = (string)book[1]; string tags = (string)book[2]; string info = (string)book[3]; string image = (string)book[4]; string bookId = (string)book[5]; string author = (string)book[6]; string compatibeMen = (string)book[7]; string nowChac = (string)book[8]; BookInStore item = new BookInStore(title, catalog, tags, info, image, bookId, author, compatibeMen, nowChac); suggestions.Add(item); } if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { sender.ItemsSource = suggestions; } }
public void Remove(BookInStore entity) { if (entity != null) { _context.BooksInStore.Remove(entity); _context.SaveChanges(); } }
public void Insert(BookInStore entity) { if (entity != null) { _context.BooksInStore.Add(entity); _context.SaveChanges(); } }
public void Update(BookInStore entity) { if (entity != null) { var oldValue = _context.BooksInStore.FirstOrDefault(x => x.Id == entity.Id); if (oldValue != null) { oldValue = entity; _context.SaveChanges(); } } }
//点击书籍,跳转到阅读页面 private async void read_Click(object sender, ItemClickEventArgs e) { BookInStore selectedItem = (BookInStore)e.ClickedItem; string bookId = selectedItem.BookId; string nowChapter = selectedItem.NowChac; progressBar.Visibility = Visibility.Visible; progressBar.IsIndeterminate = true; string content = await BookService.GetChapterContent(bookId, nowChapter); progressBar.Visibility = Visibility.Collapsed; progressBar.IsIndeterminate = false; string type = "1"; string[] parameter = { type, bookId, nowChapter, content }; this.Frame.Navigate(typeof(ReadPage), parameter); }
//搜索时切换ViewModel内容 public void ChangeViewModel(string input) { storeItems.Clear(); ObservableCollection <string[]> books = BookDB.findBookFromStore(input); foreach (string[] book in books) { string title = (string)book[0]; string catalog = (string)book[1]; string tags = (string)book[2]; string info = (string)book[3]; string image = (string)book[4]; string bookId = (string)book[5]; string author = (string)book[6]; string compatibeMen = (string)book[7]; string nowChac = (string)book[8]; BookInStore item = new BookInStore(title, catalog, tags, info, image, bookId, author, compatibeMen, nowChac); storeItems.Add(item); } }