Reputation: 2230
I have the following problem:
Upon start, my Windows Phone 8.1 App restores some settings from localStorage, and based on what it finds, should redirect the user to a login frame or directly try to authenticate her with the info found.
In my main xaml page, I extended the OnNavigatedTo
function as follows:
protected async override void OnNavigatedTo(NavigatedEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
// I added the lines here under
if(!account.IsSet)
Frame.Navigate(typeof(LoginPage));
}
So I expect that when it doesn't find an account, the user is redirected to the LoginPage. Unfortunately, it doesn't navigate, the statement is ran, but nothing happens, the user remains on the mainpage.
Any idea what I am missing? Is it the wrong place to do so? Should I cancel the current navigation first or something like this?
Upvotes: 0
Views: 619
Reputation: 2230
Damn, you just need to formulate your question to find out the right way to search this on google and actually find what you couldn't before.
I was kind of right, there seem to be some scheduling issue there. No cancelation is required, but re-scheduling the navigation using the dispatcher directly solved my problem:
await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
Frame.Navigate(typeof(LoginPage));
});
Upvotes: 2