Questions about tombstoning in Windows Phone 7
I have a weird probleme : I navigate to a view, I check one or more CheckBox
and navigate back (I didn't override the navigateFrom
method). Then I na开发者_运维知识库vigate to my view again, and the checkbox aren't checked.
Is this even normal behavior ? I this part of the tombstonning "feature" of Windows Phone 7 ? If yes, does that mean that whenever I navigate from a view, even if its within my app, I need to save state ? (I yes, that sucks...)
It sounds like what you're doing is:
- Navigate to a page
- Change something on the UI of that page(the checkbox)
- Go back from that page
- Return to that page again
If that's what you're doing, here's what's happening.
In point 3 the page is destroyed. If you didn't save something then the sytem won't have magically saved it for you.
In point 4 a brand new page is created. If you haven't written any code to set up the UI state then it will be the default.
Presumably the checked state of the checkbox is representative of something else in your app. You should therefore probably look at binding it's checked state to the underlying setting.
Because the system can't know what is a change you want persisting and what isn't, it leaves this up to you.
It's normally best to save data or setting changes as soon as they are made. Regardless of navigating within your application, your app could get tombstoned at any point and you'll probably want to preserve the app and it's data/state so that the user doesn't lose anything or get confused as a result of tombstoning.
精彩评论