Frame.SetNavigationState Method

Definition

Overloads

SetNavigationState(String)

Reads and restores the navigation history of a Frame from a provided serialization string.

SetNavigationState(String, Boolean)

Reads and restores the navigation history of a Frame from a provided serialization string.

SetNavigationState(String)

Reads and restores the navigation history of a Frame from a provided serialization string.

public:
 virtual void SetNavigationState(Platform::String ^ navigationState) = SetNavigationState;
/// [Windows.Foundation.Metadata.Overload("SetNavigationState")]
void SetNavigationState(winrt::hstring const& navigationState);
[Windows.Foundation.Metadata.Overload("SetNavigationState")]
public void SetNavigationState(string navigationState);
function setNavigationState(navigationState)
Public Sub SetNavigationState (navigationState As String)

Parameters

navigationState
String

Platform::String

winrt::hstring

The serialization string that supplies the restore point for navigation history.

Attributes

Remarks

This method is useful to save and restore the navigation state of your app. To save the navigation state, call GetNavigationState and save the return value. To restore the navigation state, call SetNavigationState and pass it the saved value.

Calling SetNavigationState will call Page.OnNavigatedTo for the current page, with NavigationMode.Back. SetNavigationState is usually called when the Window is activated, so the current page is navigated to.

Tip

In a UWP app, GetNavigationState is typically called when the app is suspended, and SetNavigationState is called when the app is resumed. When the app is resumed after being suspended, the user expects it to be in the same state.

A Windows App SDK app does not have Suspending and Resuming events, so you should consider whether or not it's appropriate for your app to save and restore navigation state when a Window is Closed and Activated. The user might not expect the navigation state to be restored after closing a Window. For more info, see Windows App SDK app lifecycle.

Applies to

SetNavigationState(String, Boolean)

Reads and restores the navigation history of a Frame from a provided serialization string.

public:
 virtual void SetNavigationState(Platform::String ^ navigationState, bool suppressNavigate) = SetNavigationState;
/// [Windows.Foundation.Metadata.Overload("SetNavigationStateWithNavigationControl")]
void SetNavigationState(winrt::hstring const& navigationState, bool const& suppressNavigate);
[Windows.Foundation.Metadata.Overload("SetNavigationStateWithNavigationControl")]
public void SetNavigationState(string navigationState, bool suppressNavigate);
function setNavigationState(navigationState, suppressNavigate)
Public Sub SetNavigationState (navigationState As String, suppressNavigate As Boolean)

Parameters

navigationState
String

Platform::String

winrt::hstring

The serialization string that supplies the restore point for navigation history.

suppressNavigate
Boolean

bool

true to restore navigation history without navigating to the current page; otherwise, false.

Attributes

Remarks

If you call SetNavigationState with the suppressNavigate parameter set to true, Page.OnNavigatedTo is not called for the current page. The current page is also put into the BackStack. When suppressing the transition, also be sure to use GoBack or GoForward to navigate to the correct page in the navigation history. NavigateToType is also supported, however the forward stack will be cleared when it is used.

Applies to