【发布时间】:2013-09-18 11:55:03
【问题描述】:
我的应用中有一个图像列表,它们都在一个列表框中,我将源作为 URL 提供。
一切正常,可以显示来自我提供的 URL 的图像。
当我更改图像并重新加载我的ListBox 时,该更改并未反映在该图像上,它显示的是旧图像而不是新图像。
我确定,在图像更改后,我将新图像 URL 绑定到源,但它显示旧图像,我无法找到为什么会发生这种情况,这是我的代码
<ListBox Grid.Row="1" HorizontalAlignment="Left" Margin="0,81,0,0" Name="wishListListBox" VerticalAlignment="Top" Width="480" Visibility="Visible">
<ListBox.ItemTemplate>
<DataTemplate>
<Image ImageFailed="wishlistImage_ImageFailed_1" x:Name="wishlistImage" HorizontalAlignment="Left" Width="164" Margin="12,54,0,88" Stretch="Fill">
<Image.Source>
<BitmapImage CreateOptions="DelayCreation,IgnoreImageCache" UriSource="{Binding thumb_image}" />
</Image.Source>
</Image>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
这是我为我的图像设置 itemsource 的课程
[DataContract]
public class WishListResponse : INotifyPropertyChanged
{
[DataMember]
public List<string> thumb_images { get; set; }
public string thumb_image
{
get
{
if (thumb_images.Count != 0)
return thumb_images[0];
else
return "";
}
set
{
thumb_images[0] = value;
OnPropertyChanged(thumb_images[0]);
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
}
在我的主页中,我像这样绑定项目源
public static List<WishListResponse> wishlistList = new List<WishListResponse>();
wishListListBox.ItemsSource = wishlistList.ToArray();
谁能帮我刷新我的图像控件。 谢谢。
【问题讨论】:
-
你能显示列表的定义和你分配它的代码/属性吗?
标签: image windows-phone-7 windows-phone-8 windows-phone