private void MyListView_OnLoaded(object sender, RoutedEventArgs e) { MyListView.Focus(); MyListView.SelectedItem = MyListView.Items[0]; // Have to do this because the ListView doesn't fully select the first item, user would // otherwise have to press down twice to get the selection to move to the second item. KeyboardUtilities.PressKey(MyListView, Key.Down); }
async void Handle_SearchButtonPressed(object sender, System.EventArgs e) { if (!string.IsNullOrWhiteSpace(searchBar.Text)) { IEnumerable <Ordonnance> foundItems; foundItems = await(BindingContext as OrdonnancesListViewModel)._ordonnanceStorage.SearchOrdonnance(searchBar.Text.Trim()); if (!string.IsNullOrWhiteSpace(searchBar.Text)) { //foreach (var item in foundItems) //{ // item.IsSynced = true; //} if (!string.IsNullOrWhiteSpace(searchBar.Text)) { ApplyFilter(_filter, true, foundItems.ToList()); } } } else { if (string.IsNullOrWhiteSpace(searchBar.Text)) { Device.BeginInvokeOnMainThread(() => { searchBar.Unfocus(); MyListView.Focus(); }); } MyListView.ItemsSource = _filteredItems ?? (BindingContext as OrdonnancesListViewModel).Ordonnances; ApplyFilter(_filter, true, (BindingContext as OrdonnancesListViewModel).Ordonnances.ToList()); } }