如何:在导航历史记录中向前定位

更新:2007 年 11 月

本示例演示如何定位到向前导航历史记录中的项。

示例

从承载于 NavigationWindowFrame use NavigationService 或 Windows Internet Explorer 中的内容运行的代码可以在导航历史记录中一次向前定位一项。

要向前定位一项,需要在调用 GoForward 方法向前定位一项之前,先通过检查 CanGoForward 属性来检查在向前导航历史记录中是否有项。下面的示例对此进行了阐释:

void navigateForwardButton_Click(object sender, RoutedEventArgs e)
{
    // Navigate forward one page from this page, if there is an entry
    // in forward navigation history
    if (this.NavigationService.CanGoForward)
    {
        this.NavigationService.GoForward();
    }
    else
    {
        MessageBox.Show("No entries in forward navigation history.");
    }
}

CanGoForwardGoForwardNavigationWindowFrameNavigationService 实现。

说明:

如果您调用 GoForward,而在向前导航历史记录中没有项,则会引发 InvalidOperationException