0

I have right now a windows phone 8 application that uses cimbalino Toolkit navigation service in my View Model.

I have a MainPage and a AddItemPage. When a user add and item and hits the save button, I have it go back to the MainPage.

Now I want to remove the AddItemPage from the back stack. Yet I have no clue where to put "RemoveBackEntry".

chobo2
  • 83,322
  • 195
  • 530
  • 832

1 Answers1

0

RemoveBackEntry should be in the MainPage.OnNavigatedTo. But this method is called every time MainPage is shown, so you have to check if last entry on the BackStack is really the page you should remove (e.g. by passing some parameter in the query string (which will be available in OnNavigatedTo) or by examining the entries in the BackStack).

Much better approach would be to call NavigationService.GoBack() after the save on the AddItemPage.

lisp
  • 4,138
  • 2
  • 26
  • 43
  • Well right now I on save the Navigate from Cimbalino to go back to the MainPage, why would it be better to use GoBack? – chobo2 Feb 28 '14 at 17:29
  • @chobo2 because that's what you want to do - return to the previous page, so why use Navigate, when there's better logical action for it? Cimbalino's INavigationService *has* `GoBack method. – lisp Feb 28 '14 at 20:27
  • Will the GoBack RemoveBackEntry of the AddItemPage? – chobo2 Feb 28 '14 at 21:02
  • @chobo2 Yes (why not test it)? – lisp Mar 01 '14 at 12:26