Saurabh
Saurabh

Reputation: 1065

Multi page windows phone application

I have a multi page windows phone application. I have a main page and a new account page. Now when the user chooses to open a new account he is navigated to the new account page. After he inputs all the details and clicks on the 'Save' button he is navigated to the Main page by using the navigation service:

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

Now when on the main page after performing the above steps, if the user clicks on hardware 'back' button he gets navigated to the new account page. This shouldn't happen! It should just exist the application as the Main page was by default the loading page.

I have a few other pages also from where I navigate to the main page and in all of them the above scenario takes place!

Upvotes: 1

Views: 1763

Answers (3)

Teemu Tapanila
Teemu Tapanila

Reputation: 1275

When you go back to MainPage.xaml you can call this code to remove the last page.

NavigationService.RemoveBackEntry();

Upvotes: 1

Martin Liversage
Martin Liversage

Reputation: 106826

If you only can navigate from the main page to the account page you can go back to the main page (thereby "undoing" the history) by going back:

NavigationService.GoBack();

Upvotes: 2

Alan Beech
Alan Beech

Reputation: 190

Put some code for a custom action in here:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
}

Upvotes: 0

Related Questions