C# Windows.Navigation.NavigationMode Windows Phone 7

C# Windows.Navigation.NavigationMode Windows Phone 7,c#,visual-studio-2010,windows-phone-7,C#,Visual Studio 2010,Windows Phone 7,我一直在学习关于“如何:为Windows Phone保留和恢复页面状态”的教程,该教程位于,其中一行代码如下: protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { // If this is a back navigation, the page will be discarded, so there // is no need to save sta

我一直在学习关于“如何:为Windows Phone保留和恢复页面状态”的教程,该教程位于,其中一行代码如下:

protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
    // If this is a back navigation, the page will be discarded, so there
    // is no need to save state.
if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
{
    // Save the ViewModel variable in the page's State dictionary.
    State["ViewModel"] = _viewModel;
}
}
但是,visual studio似乎不喜欢这段代码,这给了我以下错误:

'System.Windows.Navigation.NavigationEventArgs' does not contain a definition for 'NavigationMode' and no extension method 'NavigationMode' accepting a first argument of type 'System.Windows.Navigation.NavigationEventArgs' could be found (are you missing a using directive or an assembly reference?) 

你知道我把这里搞砸了吗。现在考虑到'e'是System.Windows.Navigation.NavigationEventArgs,if语句后的位显示System.Windows.Navigation.NavigationMode.Back,我一辈子都不明白这是如何给出错误的

NavigationMode是System.Windows.Navigation中的枚举。尝试添加

using System.Windows.Navigation;