我一直在关注http://goo.gl/ct7ui上关于“如何:为 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,我一辈子都不会看到这是如何给出错误的