简体   繁体   中英

how to save ui state on suspending Windows phone 8.1 rt xaml c#

I found basic pages for suspend an app on windows phone 8.1 but I didn't find how to save UI state on suspending. I'm making an audio player app which have in mainpage a grid which I display or not and it contains media buttons, thumbnail, slider etc. When app is forced to suspend itself and I reopen it, it restart like first opening so it lose the app state. How can I save all app state?

Bind all relevant UI States to some object (aka ViewModel ) and serialize these states upon suspending.

The basic page template also includes methods like SaveState and LoadState including a serialized dictionary, where you can store those values.

Another option is to set the page's NavigationCacheMode to Enabled or Required . This will keep the page in memory until your app is terminated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM