Forum Xamarin.Forms

How to prevent pages from navigating Multiple Forms

In Xamarin Forms, I have a list view and on tapping one item in the list view it will be taking us to the next content view. If I am tapping the item in the list view quickly for multiple times we can see the screens are navigated multiple times. How can we avoid it?


  • NMackayNMackay GBInsider, University admin


    This topic is covered extensively in forum posts but this approach should work for you.

    SomeCommand = new Command (OnCommand,(x)=> CanNavigate);
    async void OnCommand (object obj)
            CanNavigate = false;
            await CurrentPage.DisplayAlert ("Hello", "From intelliAbb", "OK");
            CanNavigate = true;

    Here's the original SO post

    Check out the blog post as well, it's worth reading

  • AshaarAshaar USMember ✭✭
    edited July 2019

    Try this.

     if (Application.Current.MainPage.Navigation.NavigationStack.Count == 0 || 
                    Application.Current.MainPage.Navigation.NavigationStack.Last().GetType() != typeof(ImageTypePage))
                    await navigationService.PushTo(new ImageTypePage(keys, IoCContainer.Container.Resolve<ImageTypeViewModel>()));
  • ayberkzerayayberkzeray USMember
    edited February 2020

    I use this in my NavigationService

                if (CurrentApplication.MainPage is NavigationPage navigationPage)
                                    if (_currentPage != null &&  _currentPage.GetType() == page.GetType())
                                    _currentPage = page;
                                    await navigationPage.PushAsync(page, animate);
Sign In or Register to comment.