Defterniko
Defterniko

Reputation: 193

Windows.Navigation.NavigationMode Windows Phone 7

I have been following this tutorial about "How to: Preserve and Restore Page State for Windows Phone" found at http://goo.gl/ct7ui and one of the lines of code is this:

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

However visual studio does not seem to like this bit of code giving me the error below:

'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?) 

Any ideas on what i've messed up with here. Now considering 'e' is System.Windows.Navigation.NavigationEventArgs and the bit after the if statement shows System.Windows.Navigation.NavigationMode.Back, i don't for the life of me see how this is giving an error

Upvotes: 2

Views: 769

Answers (1)

Gambit
Gambit

Reputation: 2525

NavigationMode is an enum in System.Windows.Navigation. Try adding

using System.Windows.Navigation;

Upvotes: 2

Related Questions