private void PreButton_Click(object sender, RoutedEventArgs e) { if (currentPage > 1) { var number = NumberOfRecipePerPage(); currentPage = currentPage - 1; RecipesList toShow = _favoriteList.GetByPage(currentPage, number); if ((currentPage) % maxButtonPerPage == 0 && currentPage - 1 < maxPage) { int temp = currentPage + 1 - maxButtonPerPage; ChangeListButton(temp, currentPage); } foreach (Button button in SkipButton.Children) { if (button.Content.ToString() == (currentPage).ToString()) { BrushConverter bc = new BrushConverter(); button.Background = (Brush)bc.ConvertFrom("#ed81a1"); } else { button.Background = Brushes.White; } } ; dataListView.ItemsSource = toShow.GetBindingData(); } }
private void PageNumber_Click(object sender, RoutedEventArgs e) { var number = NumberOfRecipePerPage(); string[] separator = new string[] { "_" }; string pageNumber = (sender as Button).Name; foreach (Button button in SkipButton.Children) { button.Background = Brushes.White; } ; BrushConverter bc = new BrushConverter(); (sender as Button).Background = (Brush)bc.ConvertFrom("#ed81a1"); var tokens = pageNumber.Split(separator, StringSplitOptions.None); int nextPage = int.Parse(tokens[1]); RecipesList toShow = _favoriteList.GetByPage(nextPage, number); dataListView.ItemsSource = toShow.GetBindingData(); }
private void NextButton_Click(object sender, RoutedEventArgs e) { if (currentPage < maxPage) { var number = NumberOfRecipePerPage(); currentPage = currentPage + 1; RecipesList toShow = recipeList.GetByPage(currentPage, number); if ((currentPage - 1) % maxButtonPerPage == 0 && currentPage - 1 < maxPage) { int temp = currentPage + maxButtonPerPage; if (temp > nearestNumberDivideByFive(temp) && temp <= maxPage) { temp = nearestNumberDivideByFive(temp); ChangeListButton(currentPage, temp); } else { ChangeListButton(currentPage, maxPage); } } foreach (Button button in SkipButton.Children) { if (button.Content.ToString() == (currentPage).ToString()) { BrushConverter bc = new BrushConverter(); button.Background = (Brush)bc.ConvertFrom("#ed81a1"); } else { button.Background = Brushes.White; } } ; dataListView.ItemsSource = toShow.GetBindingData(); } }