【问题标题】:How to cache downloaded images如何缓存下载的图像
【发布时间】:2013-05-02 20:26:21
【问题描述】:

我正在使用下面的代码将所有数据直接绑定到列表中,包括图像

void ListPostComingsoon_Completed(object sender, ListPostComingsoonCompletedEventArgs e)
    {
        ComingSoonList.ItemsSource = e.Result;

    }

List 结构如下所示

select new post
              {

                  postid = (int)r.postid,
                  userid = (int)r.userid,
                  NofLikeString = r.NofLike.ToString() + " Likes",
                  title = r.title,
                  startdate = r.startdate.ToString(),
                  enddate = r.enddate.ToString(),
                  image =   "http://localhost:6848/photo/" + r.image

              }).ToList();

如何实现图片缓存(图片下载后单独显示)?

【问题讨论】:

标签: c# windows-phone-7


【解决方案1】:

我已经为你找到了解决方案。它是JetImageLoader,我为应用程序创建了它,我们需要在其中加载、缓存和显示大量徽标、图标等。

它可以用作绑定转换器,所以你甚至不应该改变你的代码!只需更新您的 XAML!

请查看samples in repository,您会喜欢的;)

特点:

  • 在磁盘上缓存
  • 内存缓存
  • 完全异步
  • 可用作绑定转换器或以编程方式从您的代码中获得
  • 完全开源,fork 和改进它!

示例如下:

<Image Source="{Binding ImageUrl, Converter={StaticResource MyAppJetImageLoaderConverter}}"/>

附:很抱歉,我从另一个问题中复制了我的答案,但是 Windows Phone 上的图像缓存是个大问题,我想分享我的解决方案,以便每个人都可以使用它并为开发者社区改进

【讨论】:

    猜你喜欢
    • 2019-06-11
    • 2017-09-08
    • 2019-02-05
    • 2015-10-08
    • 1970-01-01
    • 2020-03-03
    • 2011-06-29
    • 2013-02-10
    • 1970-01-01
    相关资源
    最近更新 更多