protected void FilterPlayer(string sbText) { PlayersListView.BeginRefresh(); if (string.IsNullOrWhiteSpace(sbText)) { PlayersListView.ItemsSource = viewModel.players; } else { PlayersListView.ItemsSource = viewModel.players.Where(x => x.FullName.ToLower().Contains(sbText.ToLower())); } PlayersListView.EndRefresh(); }
protected override void OnAppearing() { base.OnAppearing(); if (PlayersListView.ItemsSource == null) { PlayersListView.BeginRefresh(); viewModel.LoadPlayersCommand.Execute(null); PlayersListView.ItemsSource = viewModel.players; PlayersListView.EndRefresh(); } else { FilterPlayer(sbPlayers.Text); } }
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e) { PlayersListView.BeginRefresh(); if (!string.IsNullOrWhiteSpace(e.NewTextValue)) { PlayersListView.ItemsSource = HelperClass.AllPlayers.Where(x => x.FirstName.ToLower().Contains(e.NewTextValue.ToLower()) || x.LastName.ToLower().Contains(e.NewTextValue.ToLower())).OrderBy(x => x.FirstName).ThenBy(x => x.LastName); } else { PlayersListView.ItemsSource = HelperClass.AllPlayers.OrderBy(x => x.FirstName).ThenBy(x => x.LastName); } PlayersListView.EndRefresh(); }