Search code examples
xamlwindows-phone-7windows-phone-8windows-phone-8.1

windows phone app navigation error: NavigationService does not exist in current Context


I am developing a small windows phone application.

I want to navigate from MainPage.xaml to secondPage.xaml

NavigationService.Navigate(new Uri("SecondPage.xaml", UriKind.Relative));

But it show an error message that NavigateService does not exist in current Context


Solution

  • Since you are working on a Windows Phone XAML app, you need to handle navigation using the Frame property of page, like this

    this.Frame.Navigate(typeof(SecondPage));
    

    Also, as you see above, you need to pass typeof(Page) instead of Uri.