Click or drag to resize
NavigationHelper Class
NavigationHelper aids in navigation between pages. It provides commands used to navigate back and forward as well as registers for standard mouse and keyboard shortcuts used to go back and forward in Windows and the hardware back button in Windows Phone. In addition it integrates SuspensionManger to handle process lifetime management and state management when navigating between pages.
Inheritance Hierarchy

Namespace: foodez.Common
Assembly: foodez.WindowsPhone (in foodez.WindowsPhone.exe) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class NavigationHelper : DependencyObject

The NavigationHelper type exposes the following members.

Constructors
  NameDescription
Public methodNavigationHelper
Initializes a new instance of the NavigationHelper class.
Top
Methods
  NameDescription
Public methodCanGoBack
Virtual method used by the GoBackCommand property to determine if the Frame can go back.
Public methodCanGoForward
Virtual method used by the GoForwardCommand property to determine if the Frame can go forward.
Public methodClearValue
Clears the local value of a dependency property.
(Inherited from DependencyObject.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAnimationBaseValue
Returns any base value established for a dependency property, which would apply in cases where an animation is not active.
(Inherited from DependencyObject.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetValue
Returns the current effective value of a dependency property from a DependencyObject.
(Inherited from DependencyObject.)
Public methodGoBack
Public methodGoForward
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodOnNavigatedFrom
Invoked when this page will no longer be displayed in a Frame. This method calls SaveState, where all page specific navigation and process lifetime management logic should be placed.
Public methodOnNavigatedTo
Invoked when this page is about to be displayed in a Frame. This method calls LoadState, where all page specific navigation and process lifetime management logic should be placed.
Public methodReadLocalValue
Returns the local value of a dependency property, if a local value is set.
(Inherited from DependencyObject.)
Public methodSetValue
Sets the local value of a dependency property on a DependencyObject.
(Inherited from DependencyObject.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyDispatcher
Gets the CoreDispatcher that this object is associated with.
(Inherited from DependencyObject.)
Public propertyGoBackCommand
RelayCommand used to bind to the back Button's Command property for navigating to the most recent item in back navigation history, if a Frame manages its own navigation history. The RelayCommand is set up to use the virtual method GoBack as the Execute Action and CanGoBack for CanExecute.
Public propertyGoForwardCommand
RelayCommand used for navigating to the most recent item in the forward navigation history, if a Frame manages its own navigation history. The RelayCommand is set up to use the virtual method GoForward as the Execute Action and CanGoForward for CanExecute.
Top
Events
  NameDescription
Public eventLoadState
Register this event on the current page to populate the page with content passed during navigation as well as any saved state provided when recreating a page from a prior session.
Public eventSaveState
Register this event on the current page to preserve state associated with the current page in case the application is suspended or the page is discarded from the navigaqtion cache.
Top
Examples
To make use of NavigationHelper, follow these two steps or start with a BasicPage or any other Page item template other than BlankPage. 1) Create an instance of the NavigationHelper somewhere such as in the constructor for the page and register a callback for the LoadState and SaveState events.
public MyPage()
{
    this.InitializeComponent();
    var navigationHelper = new NavigationHelper(this);
    this.navigationHelper.LoadState += navigationHelper_LoadState;
    this.navigationHelper.SaveState += navigationHelper_SaveState;
}

private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
{ }
private async void navigationHelper_SaveState(object sender, LoadStateEventArgs e)
{ }
2) Register the page to call into the NavigationHelper whenever the page participates in navigation by overriding the OnNavigatedTo(NavigationEventArgs) and OnNavigatedFrom(NavigationEventArgs) events.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    navigationHelper.OnNavigatedTo(e);
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
    navigationHelper.OnNavigatedFrom(e);
}
See Also