2012-08-31 98 views
2

我一直跟隨本教程的「如何:保護和恢復頁面國家對Windows Phone的」在http://goo.gl/ct7ui和代碼行的一個發現是:Windows.Navigation.NavigationMode的Windows Phone 7

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; 
} 
} 

但是視覺工作室似乎並不喜歡這段代碼給我下面的錯誤:

'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,我不會爲我的生活看到這是如何給出錯誤

+0

7.0或7.5項目? – Ku6opr

+0

7.5抱歉忘了說 – Defterniko

回答

2

NavigationMode是System.Windows.Navigation中的枚舉。嘗試加入

using System.Windows.Navigation;