Share via


Frame.GetNavigationState Method

Definition

Serializes the Frame navigation history into a string.

public:
 virtual Platform::String ^ GetNavigationState() = GetNavigationState;
winrt::hstring GetNavigationState();
public string GetNavigationState();
function getNavigationState()
Public Function GetNavigationState () As String

Returns

String

Platform::String

winrt::hstring

The string-form serialized navigation history. See Remarks.

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 this method will call Page.OnNavigatedFrom for the current page using NavigationMode.Forward.

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.

Note

The serialization format used by these methods is for internal use only. Your app should not form any dependencies on it. Additionally, this format supports serialization only for basic types like string, char, numeric and GUID types.

Applies to

See also