//search button click private void btnSearch_Click(object sender, RoutedEventArgs e) { dgMovies.UnselectAll(); //getting the right ID of each genre type in combo box string genre = "All"; int selectedGenreIndex = cbxGenre.SelectedIndex; int selectedGenreID = genreList[selectedGenreIndex].ID; genre = selectedGenreID.ToString(); //getting selected item from year combo box int year; int.TryParse(cbxYear.SelectedValue.ToString(), out year); //getting key word value string keyword = txbKeyword.Text.ToString(); if ((keyword == "") && (genre == "0") && year == 0) { txtMessage.Text = "Please Chose or write a key word to search!3"; } else if (keyword != "" && year == 0 && genre == "0") { SearchResultMovies = MovieViewModel.SearchResultMovies(keyword, pagenum); } else { if (keyword == "") { SearchResultMovies = MovieViewModel.GetMoviesBasedOnGenre(pagenum, genre, year); } else { DiscoverMovieModel dmv = MovieViewModel.GetMoviesBasedOnGenre(pagenum, genre, year); SearchResultMovies.Total_page = dmv.Total_page; SearchResultMovies.Page = dmv.Page; SearchResultMovies.Results = new List <RootDiscoverMovieModel>(dmv.Results.Where(x => x.Title.StartsWith(keyword))); } } page = SearchResultMovies.Page.ToString(); totalpage = SearchResultMovies.Total_page; txtPageNumMax.Text = $" ... {totalpage}"; dgMovies.ItemsSource = SearchResultMovies.Results; dgMovies.Columns[0].Visibility = Visibility.Hidden; dgMovies.Columns[5].Visibility = Visibility.Hidden; dgMovies.Columns[6].Visibility = Visibility.Hidden; }