detect navigationwindow go back event

帅比萌擦擦* 提交于 2019-12-12 04:14:00

问题


how to determine when navigationwindow back button is pressed and trap that event to something extra. I am thinking of managing the page state.


回答1:


Add a handler to either NavigationWindow.Navigating or NavigationService.Navigating. In your handler:

void NavigationService_Navigating(object sender, NavigatingCancelEventArgs e)
{
    if (e.NavigationMode == NavigationMode.Back) {
        e.Cancel = true;

        // TODO: whatever state management you're going to do
    }
}

The NavigatingCancelEventArgs contains all of the information about the navigation request you'll need to manage page state.




回答2:


The NavigationService provides a number of events you can subscribe to, if you want to control the navigation process:

  • Navigating, when the frame is about to navigate. Set Cancel to true to stop.
  • Navigated, when navigation has finished but before it is rendered
  • NavigationFailed, when something goes wrong
  • NavigationProgress, when chunks of a remote navigation call are being downloaded.
  • NavigationStopped, when the StopLoading method is called or a new Navigate request is made during downloading
  • LoadCompleted, when the page has been rendered


来源:https://stackoverflow.com/questions/11654421/detect-navigationwindow-go-back-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!