how should a metro app cache images for tombstoning (and should it)?

两盒软妹~` 提交于 2019-12-10 12:13:57

问题


I have a c# metro app that downloads a collection of objects that have a property for a uri. This collection is bound to a ListBox with an Image source bound, this works fine.

When the app is tombstoning, I want to preserve all app state including the collection and the images that have been downloaded from the internet.

Covering the case, the users actions result in the collection being downloaded and displaying correctly they switch away to another app and the my app is terminated. The user then switches back to my app and expects exactly the same display as before but are now not connected to the internet.

Saving the collection is easy, and hooking into the ImageLoaded event on the Image is easy but how can I then save that image?

Is this required functionality, will windows automatically cache this type of http based image ?

Beware, the API has changed for RP and the commonly found examples using WritableBitmap no longer work as the constructor can no longer accept an ImageSource.

Update:

Metro APP - BitmapImage to Byte[] or Download Image from Web and convert it to a Byte[] Array that's what I was afraid of, those do not use the existing working bound image element but make a separate http call. I really do not want to download all my images twice. I will try a spike and see if windows caches the http request in this scenario.


回答1:


This answer echoes the previous answer that was removed.

The only way to provide the required user experience described above is to manually cache the images locally. Nothing in this realm is done for the programmer.

What was not presented was the coded solution, a new question has been created to address this. How can I save an image from an ImageSource without downloading again?



来源:https://stackoverflow.com/questions/11101771/how-should-a-metro-app-cache-images-for-tombstoning-and-should-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!