我想解决这个问题,当我多次按下按钮时 - 提供了许多相同的页面。我在这里找到了这样的代码。
var stack = Navigation.NavigationStack;
if (stack[stack.Count - 1].GetType() != typeof(DetailsPage))
await Navigation.PushAsync (new DetailsPage ());
Navigation.NavigationStack - 工作正常。
Navigation.ModalStack - 不t work. But I can
获取名称。
请帮我解决这个问题。
答案 0 :(得分:6)
在这个常见问题上有各种各样的主题,我可以在论坛上看到你已经评论过它,还有NavigationExtensions
类:
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);
}
}
}
以下是讨论: https://forums.xamarin.com/discussion/29787/double-tapping-in-xamarin-forms-on-android