在 Windows Phone 8.1 通用应用程序中本地保存图像 [英] Saving images locally in windows phone 8.1 universal app

查看:39
本文介绍了在 Windows Phone 8.1 通用应用程序中本地保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Windows Phone 8.1 通用应用程序中本地下载和保存(缓存)图像.这样如果电话离线,我可以在 ListView 中显示用户图像(头像).

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. 将图像保存到本地存储的最佳方式是什么(我应该使用本地存储还是使用 sqlite,因为我正在使用 sqlite 存储用户的其他信息)?

  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)?

如何将图像保存(下载)到本地存储?

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

谢谢!

推荐答案

Q42 在其 Q42.WinRT 框架中有一个很棒的扩展,名为 ImageExtensions.cs

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

您在 XAML 中的普通 Image 对象上使用它,但不是设置 Image 的 Source,而是设置 ImageExtensions.CacheUri.

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 只是在 XAML 页面顶部添加的命名空间

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!

这篇关于在 Windows Phone 8.1 通用应用程序中本地保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆