Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

IProvideCustomContentState Interface

Implemented by a class that needs to add custom state to the navigation history entry for content before the content is navigated away from.

Namespace:  System.Windows.Navigation
Assembly:  PresentationFramework (in PresentationFramework.dll)
public interface IProvideCustomContentState

The IProvideCustomContentState type exposes the following members.

  NameDescription
Public methodGetContentStateReturns an instance of a custom state class that is to be associated with content in navigation history.
Top

IProvideCustomContentState allows you to associate a piece of custom state, implemented as a custom CustomContentState class, with the navigation history entry for content that has been navigated away from.

Custom state can also be associated in this way by using the following:

You must implement IProvideCustomContentState when you add custom state to navigation history by calling AddBackEntry, otherwise navigation history will not function correctly; consider the following steps:

  1. AddBackEntry is called to associate a custom state with the current content.

  2. The navigation history entry is navigated back to, and the Replay method of the custom state is called, and the state is applied to the content.

  3. The previous content is navigated to in forward navigation history.

  4. The navigation history entry is navigated back to, but the custom state has not been retained since the last time the navigation history entry it was associated with was navigated to.

This is the default behavior because the state that is initially recorded in custom state may change after it was added to navigation history. If the custom state object is navigated back to and its state is applied, before some aspect about the state changes before the entry in navigation history is navigated to, the change in state cannot be reflected in the custom state object. Furthermore, AddBackEntry can't be explicitly called to add a new custom state object that reflects the state changes. Consequently, to ensure the current state for a particular navigation is always stored in navigation history, GetContentState is called.

Important noteImportant

When you store information in custom content state, you cannot store any references to the instance of the page for which you are remembering state. This prevents WPF from releasing the page instance, and defeats the purpose of the default navigation history behavior. If you must do this, you might consider using KeepAlive instead.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.