如何避免导航堆栈上已存在打开的页面?
how to avoid open page already exist on Navigation stack?
我正在使用 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);
}
我正在使用 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);
}