ListView ItemSelected Bug

elviosousaelviosousa USMember
edited December 2015 in Xamarin.Forms

Hi there!

I checked a bug when I click in a LisView item, then If I click twice or more, it opens as many pages I clicked.
Anyone has the idea how to fix it?

ListIdeas.ItemSelected += (sender, e) => {

    if (e.SelectedItem == null) return; // don't do anything if we just de-selected the row

    this.Navigation.PushAsync(new IdeaDetailsPage());

    ((ListView)sender).SelectedItem = null; // de-select the row


  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    with buttons I use this solution. I think you can do something similar for listView

            buttonIndietro.Clicked += async (object sender, EventArgs e) => {
                    buttonIndietro.IsEnabled = false;
                    await App.MainNavigationPage.Navigation.PopAsync ();
                catch(Exception ex){
                    DisplayAlert("Attenzione", ex.Message, "Ok");
                    buttonIndietro.IsEnabled = true;
  • NMackayNMackay GBInsider, University mod


    I've seen a few approach but this worked best for me:

    public RelayCommand FavCommand
                    return _favCommand
                           ?? (_favCommand = new RelayCommand(
                               async () =>
                                       // Check for double tap if already awaiting nav
                                       if (_navSevice.CurrentPageKey == ViewModelLocator.PageKeyFav) return;
                                       await _navSevice.NavigateTo(ViewModelLocator.PageKeyFav);

    As your awaiting the navigation PushAsync if you tap on the Listitem multiple times you can check if you've already asked for that page to be served up. I have a custom navigation service which wraps the Forms Navigation service but you could use a variable instead in your page codebehind or viewmodel.

Sign In or Register to comment.