private void nextButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(searchBox.Text) && classificationListView.SelectedIndex == -1 && showFavoriteCheckBox.IsChecked == false) { if (PageInfomation.currentPage != PageInfomation.total()) { PageInfomation.currentPage += 1; updatePageInfomation(); dataListView.ItemsSource = Global.data.recipes.Skip((PageInfomation.currentPage - 1) * PageInfomation.pageSize).Take(PageInfomation.pageSize); } } else { if (filterResultRecipes.Count() != 0) { if (PageInfomation.currentPage != PageInfomation.total()) { PageInfomation.currentPage += 1; updatePageInfomation(); dataListView.ItemsSource = filterResultRecipes.Skip((PageInfomation.currentPage - 1) * PageInfomation.pageSize).Take(PageInfomation.pageSize); } } } }
/// <summary> /// Cập nhật thông tin phân trang /// </summary> private void updatePageInfomation() { pageInfomationText.Text = $"{PageInfomation.currentPage} / {PageInfomation.total()}"; if (PageInfomation.currentPage == PageInfomation.total()) { nextButton.IsEnabled = false; } else { nextButton.IsEnabled = true; } if (PageInfomation.currentPage == 1 || PageInfomation.currentPage == 0) { previousButton.IsEnabled = false; } else { previousButton.IsEnabled = true; } }