3

I've got a problem with navigate to next page in section:

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
            Debug.WriteLine("Test1");
            Frame.Navigate(typeof(LoginView));
            Debug.WriteLine("Test2");            
    }

The method Frame.Navigate didn't work at all if only it's call in OnNavigatedTo. On debug I see "Test1" and "Test2" but nothing else happens. Any idea? The project: Windows Phone Store App 8.1

Criss
  • 725
  • 1
  • 6
  • 12

2 Answers2

2

Add async keyword to OnNavigatedTo method and add await Task.Delay(10); before Frame.Navigate() call. Alternatively, you can execute Frame.Navigate() in Dispatcher.

1) using delay

protected override async void OnNavigatedTo(NavigationEventArgs e)
{
    await Task.Delay(10);
    Frame.Navigate(typeof (LoginView));
}

2) using Dispatcher

protected override async void OnNavigatedTo(NavigationEventArgs e)
{
    Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        Frame.Navigate(typeof(LoginView));
    });
}
Lukáš Neoproud
  • 872
  • 3
  • 10
  • 20
1

I also faced the very same issue and it was caused because I had some Xaml not being resolved properly on second page. Check for Xaml being proper and all resource and references being right.