WPF supports browser-style navigation when you create stand-alone or browser-based applications. You can use this approach when you want to build applications that require a concept of navigation, such as wizards or help applications. You can navigate from one page to another in two ways: declaratively by using hyperlinks or programmatically by using the NavigationService class.

WPF provides three ways to navigate between pages in an application:

  1. Navigate from one page to another page.
  2. Navigate to a fragment within a page.
  3. Navigate between subcontent frames in a page.

Maintaining State by Using Navigation Services

In WPF, when you navigate away from a page, the page is destroyed; when you go back or forward to a page, the page is re-created. The purpose of this implementation is to save memory. Often, pages are not revisited after they are initially rendered, so the default behavior of WPF is to discard a page after you leave it. However, because any controls on a page that collect data are also created anew, any previous data is lost. Therefore, you may wish to alter the default behavior in WPF to maintain the state of certain pages. You can do this by setting the KeepAlive property in the navigation journal, by using dependency properties, or by implementing the IProvideCustomContentState interface.