Pressing buttons multiple times loads multiple pages (Android)

前端 未结 1 1481
梦如初夏
梦如初夏 2021-01-07 07:42

I want to solve the problem, when I push the button several times - offers many of the same pages. I found here such code.

var stack = Navigation.NavigationS         


        
1条回答
  •  有刺的猬
    2021-01-07 08:10

    there are various threads on this common issue, I can see on the forums that you already commented on it, there are also NavigationExtensions class:

    public static class NavigationExtensions
    {
        public static async Task PushModalAsyncSingle(this INavigation nav, Page page, bool animated = false)
        {
            if (App.Navigation.ModalStack.Count == 0 || 
                App.Navigation.ModalStack.Last().GetType() != page.GetType())
            {
                await nav.PushModalAsync(page, animated);
            }
        }
    
        public static async Task PushAsyncSingle(this INavigation nav, Page page, bool animated = false)
        {
            if (App.Navigation.NavigationStack.Count == 0 ||
                App.Navigation.NavigationStack.Last().GetType() != page.GetType())
            {
                await nav.PushAsync(page, animated);
            }
        }
    }
    

    Here is the discussion: https://forums.xamarin.com/discussion/29787/double-tapping-in-xamarin-forms-on-android

    0 讨论(0)
提交回复
热议问题