Reputation: 77
I have a problem with my navigation stack.
I have three pages and in the first one I have a PushAsync to the second page in the OnAppearing Trigger. The second page has a PushAsync to the third page in the constructor.
So this is what the stack should look like:
Page1 > Page2 > Page3
However, the stack looks like this
Page1 > Page3 > Page2
So my question is, do you call pushasync in constructor or don't do it. I'm still at the beginning so I don't know what to do and what not to do.
Upvotes: 0
Views: 133
Reputation: 445
You can't give await operator in Constructor So to obtain result you can do as this.
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());
}
Upvotes: 1
Reputation: 7179
You are most likely not awaiting the Push Methods, that's why you can have a wrong order in your Navigation Stack:
await Navigation.PushAsync(new YourPage());
Upvotes: 1