Xaml NavigationService.Navigate抛出异常并调用WP8中未处理的应用程序异常

Xaml NavigationService.Navigate抛出异常并调用WP8中未处理的应用程序异常,xaml,windows-phone-8,windows-phone,navigationservice,Xaml,Windows Phone 8,Windows Phone,Navigationservice,我正在使用VS2013开发一个简单的WP8应用程序。我有一个MainPage.xaml,并添加了一个名为Page1.xaml的新页面。当用户单击“新建项目”时,屏幕上有一个选项列表。我想打开一个新页面来添加新项目(例如Page1.xaml)。 在列表选择更改事件中,我编写了以下代码: private void OptionssList_SelectionChanged(object sender, SelectionChangedEventArgs e) { va

我正在使用VS2013开发一个简单的WP8应用程序。我有一个MainPage.xaml,并添加了一个名为Page1.xaml的新页面。当用户单击“新建项目”时,屏幕上有一个选项列表。我想打开一个新页面来添加新项目(例如Page1.xaml)。
在列表选择更改事件中,我编写了以下代码:

    private void OptionssList_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var selection = (MenuItem) e.AddedItems[0];
        switch (selection.Id)
        {
            case 0:
                break;
            case 1:
                break;
            case 2:
                this.NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
                break;
            case 3:
                break;
            default:
                break;
        }
    }
当我尝试调试应用程序时,我注意到如果我有一个OnNavigatedTo事件处理程序,则会调用Page1.xaml的构造函数,但在所有这些之后,会引发一个未处理的异常。当抛出异常时,我看不到任何代码,但是它调用了应用程序\u UnhandledException事件处理程序

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
        if (Debugger.IsAttached)
        {
            // An unhandled exception has occurred; break into the debugger
            Debugger.Break();
        }
    }
异常详细信息如下所示:

System.NullReferenceException was unhandled
Message: An unhandled exception of type 'System.NullReferenceException' occurred in System.Windows.ni.dll
Additional information: Object reference not set to an instance of an object.

我想知道我是否遗漏了什么。我参考了示例,它也显示了类似的导航方式,没有注意到任何花哨的东西。

我知道这可能是一个非常愚蠢的问题,你的代码在我看来很好,你的页面可能不在另一个文件夹中吗?我总是将我的页面放在一个名为UI的文件夹中,因此我的代码将如下所示:

                                         /folder1/folder2/pagename
this.NavigationService.Navigate(new Uri("/UI/Generics/Page.xaml", UriKind.Relative));

请确保这一点,因为这通常会让我明白。

也许我们需要更多的细节来了解发生了什么。您的Page1.xaml可能有问题,它是否包含特殊内容?我的第一页上没有任何特殊内容。。我刚刚创建了一个新页面,但尚未添加任何控件。我的两个页面都位于根文件夹中。