Can I find out on which page the user appeared by clicking the back button on WP7?

I was not lucky to find the answer through Google search queries, but can I find out which page the user came from?

Or send a query string to the back button so I can tell?

Basically, I have a page that I don’t want the user to go to by clicking the "Back" button - the only way they should get is if they followed the process from the very beginning. A good example of what I'm trying to do is that a user cannot go back to setting up confirmation when registering for an account after they are already successfully registered. I would prefer them to go to the start of registration.

+5
source share
5 answers

You can use the NavigationService.BackStack property and check the first entry in the reverse stack on the page as it is moved.

If this check is to be performed on several pages, it can be placed in the base class. Also, if your situation matches the eula / login script mentioned by @Skomski, his answer makes the most sense.

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    var lastPage = NavigationService.BackStack.FirstOrDefault();

    if (lastPage != null && lastPage.Source.ToString() == "/MainPage.xaml")
    {
        NavigationService.RemoveBackEntry();
    }
}
+9
source

Basically you want to delete your NavigationEntrys.

To do this, use NavigationService.RemoveBackEntry .

You can access the NavigationService from anywhere using this snippet:

(App.Current.RootVisual as PhoneApplicationFrame).RemoveBackEntry()

The best decision:

EULA/Login ( Splash) - . Popup Dialog, ( , "" , - ..), backstack.

: http://blogs.msdn.com/b/ptorr/archive/2010/08/01/exiting-a-windows-phone-application.aspx

+4

- OnBackKeyPress ( , ). . , , , .

+1

I cannot think of a way to directly detect depression.

What about a session variable that records the current step of the process?

0
source

You can use the NavigationService to achieve the desired result. In particular, you can do something like this:

var uri = NavigationService.CurrentSource;
if(uri != badUri) { /*proceed...*/ } 

Here is this page:

http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.currentsource.aspx

0
source

All Articles