Silverlight Navigation: How to remember page state?
I'm not sure how to preserve page state in Silverlight 4.
I have a page called SearchPage
. The user comes to it with a query, but the query may change while the user is ther开发者_开发问答e. If the user goes back, I'd like the most recent version of the query to be retained, not the original one.
To do this, I overrode OnFavigatedFrom()
and changed NavigationContext.QueryString
to reflect the new values. Then, in OnNavigatedTo()
, I check for those values.
Unfortunately, this doesn't work. It appears that I can't change the query string, because when I call navigator.GoBack()
, it goes back to the original query string.
What other way can I preserve page state?
You can set the NavigationCacheMode property on the Page to Enabled or Required, which will cache and retain the page's state when it's navigated away from.
精彩评论