Files
docs-desktop/dotnet-desktop-guide/framework/wpf/app-development/how-to-navigate-back-through-navigation-history.md
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.6 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Navigate Back Through Navigation History 03/30/2017
csharp
vb
history [WPF], navigating back
navigation [WPF], through navigation history (back)
9343234b-d864-441d-b8a7-d895cba80a87

How to: Navigate Back Through Navigation History

This example illustrates how to navigate to entries in back navigation history.

Example

Code that is running from content that is hosted in a xref:System.Windows.Navigation.NavigationWindow, xref:System.Windows.Controls.Frame using xref:System.Windows.Navigation.NavigationService, or Internet Explorer can navigate back through navigation history, one entry at a time.

Navigating back one entry requires first checking that there are entries in back navigation history, by inspecting the CanGoBack property, before navigating back one entry, by calling the GoBack method. This is illustrated in the following example:

[!code-csharpHOWTONavigationSnippets#NavigateBackCODE] [!code-vbHOWTONavigationSnippets#NavigateBackCODE]

CanGoBack and GoBack are implemented by xref:System.Windows.Navigation.NavigationWindow, xref:System.Windows.Controls.Frame, and xref:System.Windows.Navigation.NavigationService.

Note

If you call GoBack, and there are no entries in back navigation history, an xref:System.InvalidOperationException is raised.