按后退按钮检查是否已到达当前页面

时间:2014-02-23 15:23:49

标签: windows-phone-8 windows-phone windows-applications navigationservice

我正在为Windows Phone 8开发一个有2页的小应用程序(1当然是主页)。

当达到 page2 时,我想通过按手机上的后退按钮来检查是否已到达此页面。我想做这样的事情:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    if (backButton.isPressed()) {
        // this page has been reached by pressing the back button on the phone
    } else {
        // this page has been reached by NavigationService.Navigate()
    }
}

是否有原生API可以做到这一点?

1 个答案:

答案 0 :(得分:3)

这是你需要的吗?

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (e.NavigationMode == NavigationMode.Back)
    {
        ...
    }
}