Saving images locally in windows phone 8.1 universal app

[亡魂溺海] 提交于 2019-12-05 07:27:11

问题


I want to download and save(cache) images locally in windows phone 8.1 universal app. so that if Phone is offline I can show users images(avatars) in ListView.

  1. What is the best way of saving images to local storage(should I use local storage or I use sqlite as i am using sqlite to store user's other information)?

  2. How can I save (download) images to local store?

Thanks!


回答1:


There's a great extension by Q42 in their Q42.WinRT framework called ImageExtensions.cs

You use it on normal Image objects in XAML, but instead of setting the Source of the Image, you set the ImageExtensions.CacheUri.

<Image q42controls:ImageExtensions.CacheUri="https://www.google.com/favicon.ico" />

q42controls is just a namespace added on top of the XAML page

xmlns:q42controls="using:Q42.WinRT.Controls"

When the image is loaded, it's automatically cached!



来源:https://stackoverflow.com/questions/24797604/saving-images-locally-in-windows-phone-8-1-universal-app

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