【问题标题】:Xamarin Forms: Navigation stack has wrong orderXamarin Forms:导航堆栈的顺序错误
【发布时间】:2018-07-16 08:07:40
【问题描述】:
我的导航堆栈有问题。
我有三个页面,在第一个页面中,我有一个 PushAsync 到 OnAppearing 触发器中的第二个页面。第二页有一个 PushAsync 到构造函数中的第三页。
所以堆栈应该是这样的:
第1页>第2页>第3页
然而,堆栈看起来像这样
第1页>第3页>第2页
所以我的问题是,你是在构造函数中调用 pushasync 还是不这样做。
我还处于起步阶段,所以我不知道该做什么不该做什么。
【问题讨论】:
标签:
xamarin
xamarin.forms
【解决方案1】:
你不能在构造函数中给await操作符所以要得到结果你可以这样做。
Public Constructor()
{
Doit();
}
public async void Doit()
{
// In fisrt page insert second page..
//In second page too do the same while inserting third Page
await await Navigation.PushAsync(new YourPage());
}
【解决方案2】:
您很可能没有等待推送方法,这就是您的导航堆栈中可能有错误顺序的原因:
await Navigation.PushAsync(new YourPage());