Windows Phone 8 图像绑定 [英] Windows Phone 8 Image Binding

查看:21
本文介绍了Windows Phone 8 图像绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个图像 URL 绑定到我的 Windows Phone 8 应用程序中的图像控件,代码如下:

I want to bind an image-url to an image control in my Windows Phone 8 app, here's the code:

<ListBox x:Name="ImageList" SelectionChanged="spotlightListBox_SelectionChanged"  >
   <ListBox.ItemTemplate>
      <DataTemplate>
         <Grid Width="420">
            <StackPanel Height="325" VerticalAlignment="Top">
               <Image x:Name="eventImage" Source="{Binding ImageUrl}" VerticalAlignment="Top"/>
            </StackPanel> 
         </Grid>  
      </DataTemplate>
   </ListBox.ItemTemplate>
</ListBox>

通过这种方式我得到ag_e_network_error".ImageUrl 正在工作,我在不同的页面中使用相同的 URL,它们工作正常.我只在这段代码中得到错误.我不明白错误的原因.ListBox Itemsource 是一个通用列表.

With this way i get "ag_e_network_error". The ImageUrl is working, I use the same URL in different pages and they work fine. I get the error only in this code. I don't understand the reason of the error. ListBox Itemsource is a generic list.

ImageList.ItemsSource = spotlightInfo.Spots;

Spots 对象是一个通用列表.像这样.

Spots object is a genereic list. And Like this.

public string Name { get; set; }
public string Type { get; set; }
public string Text { get; set; }
public string ImageUrl { get; set; }

图片网址如 www.someurl.com/someImage.jpg

在可能出现问题的地方提供一些帮助将不胜感激.

Some assistance on where there may be an issue would be appreciated.

推荐答案

尝试将 ImageUrl 的类型从字符串更改为 Uri

Try changing the type of ImageUrl from string to Uri

这篇关于Windows Phone 8 图像绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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