Saving images locally in windows phone 8.1 univers

2019-04-02 11:19发布

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条回答
混吃等死
2楼-- · 2019-04-02 11:56

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!

查看更多
登录 后发表回答