Xaml frame navigation returns false

Hello,
I am working in a simple Windows 8 application with xaml and C #. I use VS 2012 templates to create pages with the navigation system turned on.

I download a lot of data, so I decided to add a download page with ProgressRing and go to the first page of the application when the data download is completed:

//loading page
protected async override void OnNavigatedTo(NavigationEventArgs e) {
...
await topCookerManager.GetBlogsAsync();
this.Frame.Navigate(typeof(MainPage));
...
}

It works well when the application starts, but when I am on the first page of the application, and when I click the "Back" button, I am redirected to the download page. So, on the download page, I check if the data is loaded, and if so, then I will be redirected to the first page.

if (dataManager.Blogs != null && dataManager.Blogs.Count > 0)
this.Frame.Navigate(typeof(MainPage));

** Problem **: I cannot go from this point. The Navigate method returns false! I tested the * GoFormard * method, it doesn’t exclude, but the navigation fails, and I stay on the download page ...

Could you tell me where is my mistake? Or how to implement a download page.
Thank you for your help.

+5
source share
1 answer

You cannot Navigatefrom the method OnNavigatedTo, since the previous navigation method is still executing at this point. Instead, you can wait for it to load by making a new navigation call through the dispatcher.

protected async override void OnNavigatedTo(NavigationEventArgs e)
{
     //your other code
     //...
     Dispatcher.RunAsync(CoreDispatcherPriority.Normal, 
                            () => Frame.Navigate(typeof(MainPage))); 
}

, , , . , .

, , , , Xyroid, .

+15

All Articles