简体   繁体   中英

WP7 page navigation?

Initially I am navigating from one to another XAML class like this (for example, from MainPage.xaml to Firstpage.xaml):

 this.NavigationService.Navigate(new Uri("/Firstpage.xaml", UriKind.Relative));

This works fine, but I want to exit the application when hitting the back button. When I navigate like this, the back button takes me back to the previous page (MainPage.xaml). How can I accomplish this?

You can use the RemoveBackEntry method to remove the page you come from.

http://msdn.microsoft.com/en-us/library/hh394012(v=VS.92).aspx

But in Windows Phone, navigation has to follow some rules. Remember that users expect to return to the previous page with the back button. That's how navigation in Windows Phone is supposed to work. Except in a few cases.

If you just want your user to see a page once, when they launch the application, you can put the content of that page in a grid on your second page, and just hide it when it's not necessary.

In that way, when the user will hit the back button, the application will quit and you won't have to manipulate the navigation stack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM