How to finish current page in Windows Universal

拥有回忆 提交于 2019-12-08 06:46:29

问题


How can I close the current active Page in UWP development?

I want to start a new Page and close the current one, so the user cannot go back to that page. Is there any method in UWP similar to Android's method "finish()"?


回答1:


I think you should be able to do this by removing last page from back stack after navigating to a new one. Sample code in OnNavigatedTo of a new page:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    this.Frame.BackStack.RemoveAt(this.Frame.BackStack.Count - 1);
}

This should prevent user from going back to last page. Of course you can modifay the back stack in many ways if you need.



来源:https://stackoverflow.com/questions/35090382/how-to-finish-current-page-in-windows-universal

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