开发者

Silverlight Navigation: How to remember page state?

开发者 https://www.devze.com 2023-01-29 02:00 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消