c# - 如何避免导航堆栈上已存在打开的页面?

标签 c# xamarin.ios xamarin.android xamarin.forms portable-class-library

<分区>

我正在使用 Xamarin.forms,有时用户会在同一个按钮上点击两次,我正在搜索以避免打开同一页面两次,也许在第一次点击后禁用按钮会很好,但是如果页面已存在于导航堆栈中,我正在搜索以避免打开同一页面。

btnCustomerPage.Clicked += (object sender, EventArgs e) => 
{
 //CustomerPage already Exist on Navigation Stack,So user already open it.
 Navigation.PushAsync(new CustomerPage(); 
};

最佳答案

if (Navigation.NavigationStack.Count == 0 ||
    Navigation.NavigationStack.Last().GetType() != typeof(CustomerPage))
{
    await Navigation.PushAsync(new CustomerPage(), true);
}

关于c# - 如何避免导航堆栈上已存在打开的页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42375403/

相关文章:

c# - C# 中的 Moq Application.Current.MainWindow

c# - 你能用参数做一些像 RoutePrefix 这样的事情吗?

c# - Xamarin Android 将数据从类传递到 Activity

android - SERVICE_NOT_AVAILABLE,同时使用 Xamarin for Android 注册 Google Cloud Messaging

c# - 为什么关闭的 Android Activity 似乎保留对象?

c# - xamarin 上的 HttpClient PostAsync 什么都不做

c# - 垃圾邮件发送者导致的 EndOfStreamException

c# - 在哪里写日志文件?

visual-studio-2015 - Visual Studio 未部署到 iOS 模拟器

ios - Xamarin iOS Storyboard, subview 半宽然后是父 View 。看法