Tombstoning after page navigation

Feb 26, 2011 at 8:55 AM

I have WP7 app with a main page and a second page.

The view model for the first page has some properties with [SurviveTombstone] set. These work as expected when you jump out of the app and back again.

However, if you navigate to the second page and then jump out of the app and back, the first page's tombstone properties are not persisted.

If I weren't using CM, then I'd be settings and reading from the page's State property in the OnNavigatedTo and OnNavigatedFrom event handlers.

Is there a way to get CM to do this automatically?


Feb 26, 2011 at 5:03 PM

You might consider using INavigationService events, which should be equivalent to those in the page.

Feb 27, 2011 at 12:01 AM

That's indeed my current plan.

Just double-checking that there wasn't something already built-in that would do it automatically.


Mar 6, 2011 at 8:31 PM

Not sure if there's a bug or if it's me.. but I'm not getting any navigation events firing when I return back to the first page (step 5 below)

So the sequence is.

  1. Launch app (first page)
  2. Go to second page
  3. Jump out of app to start screen
  4. Go back (resurrects to second page)
  5. Go back (to first page)

I traced the code and the FrameAdapter's OnNavigated method is being called, but that's it.

In my AppBootstrapper class, I'm registering INavigationService like this (using Ninject)

_kernel.Bind<INavigationService>().ToConstant( new FrameAdapter( RootFrame ) );

Maybe that's not quite right?


Mar 7, 2011 at 12:01 AM

Are you re-wiring to the events after resurrection?

Mar 7, 2011 at 12:08 AM
Edited Mar 7, 2011 at 12:09 AM

I'm currently wiring up these events in the view model's constructor.

I suspect this may not be working, as when the app is resurrected, I assume it's the second page's VM that is constructed.

So I'm wondering if the INavigationService events need to be handled at an app-level rather than within a specific page?

As it is, I decided to move the code I was executing into the OnActivate/OnDeactivate overrides in the page and that seems to be working ok.

On Mon, Mar 7, 2011 at 11:31 AM, EisenbergEffect <> wrote:

From: EisenbergEffect

Are you re-wiring to the events after resurrection?


Mar 7, 2011 at 1:40 AM

I recommend using the OnActivate/OnDeactivate over wiring to events. It will make your VM code cleaner and reduce coupling.