Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6161597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:30:24+00:00 2026-05-23T21:30:24+00:00

i’ve just run into the infamous tombstoning problem/issue in WP7. let’s say i have

  • 0

i’ve just run into the infamous tombstoning problem/issue in WP7. let’s say i have 3 pages, FirstPage.xaml, SecondPage.xaml, and ThirdPage.xaml. the natural flow will be:

FirstPage.xaml -> SecondPage.xaml -> ThirdPage.xaml

in other words,

main page -> page with list of objects -> page displaying one object in detail from previous page

when i go from FirstPage.xaml to SecondPage.xaml, i have to do a database query to get a List in SecondPage.xaml. i then need to go to a ThirdPage.xaml from SecondPage.xaml (after i select one MyObject from List). at this point, tombstoning is becoming very confusing for me.

i know when going FirstPage.xaml -> SecondPage.xaml, the constructor of SecondPage.xaml.cs is called. i know when going ThirdPage.xaml -> SecondPage.xaml (going back, by hitting the back button or NavigationService.GoBack()), the constructor of SecondPage.xaml.cs is NOT called. when i move from SecondPage.xaml to ThirdPage.xaml, i store the view-model (VM) objects in PhoneApplicationService.Current.State (SecondPage.xaml.cs.OnPageNavigatedFrom()).

my (flawed) strategy was, well, if the constructor of SecondPage.xaml.cs is called in one instance (FirstPage.xaml -> SecondPage.xaml), but not in the other instance (ThirdPage.xaml -> SecondPage.xaml), then i can set a boolean flag in the constructor whether to do a fresh DB query or to restore the page’s state (from PhoneApplication.Current.State). the boolean flag is set to false initially, and only set to true in the constructor of SecondPage.xaml.cs.

i thought this worked well, but then when i pressed the start button to leave the app and then hit the back button to come back to the app, the constructor of SecondPage.xaml.cs was called. so i do another fresh DB query instead of restoring the state, which is NOT the intended behavior.

my question is this, how do i know when to do a fresh DB query vs a restore when the user hits start and then back to get to the app? i thought about how to solve this myself, but most of what i thought up were kludges; it seemed un-natural and as if i was tinkering to get things to work. for example, i thought i can pass in a querystring from FirstPage.xaml to SecondPage.xaml (i.e. /SecondPage.xaml?freshDbQuery=1), but when i move from ThirdPage.xaml back to SecondPage.xaml, that querystring key-value pair, freshDbQuery=1, is always so! (so as you can tell, i don’t know wp7 too well).

any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:30:25+00:00Added an answer on May 23, 2026 at 9:30 pm

    All your handling for tombstoning should be done in the OnNavigatingFrom** and the OnNavigatedTo events.

    You can create all purpose handlers for your situation with the following:

    protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
    {
        if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
        {
            this.State.Clear();
            this.State.Add("db_data", ***Serialized version of the DB returned data***);
        }
    
        base.OnNavigatingFrom(e);
    }
    
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        if (this.State.ContainsKey("db_data"))
        {
            this.SomethingOnPage = DeserializeToAppropriateType(this.State["db_data"]);
        }
    
        base.OnNavigatedTo(e);
    }
    

    ** Use this in preference to OnNavigatedFrom wherever possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a jquery bug and I've been looking for hours now, I can't
I would like to run a str_replace or preg_replace which looks for certain words
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.