这里我想在动态列表中显示图像,图像从数据绑定LineFour获取源代码,这是代码。
<Image Height="100" Width="100" Source="{Binding LineFour}" Margin="12,0,9,0"/>
我在加载数据
中有这个public void LoadData()
{
// Sample data; replace with real data
this.Items.Add(new ItemViewModel() { LineOne = "beach 1", LineTwo = "hill 1", LineThree = "monu 1", LineFour="file3"});
this.Items.Add(new ItemViewModel() { LineOne = "beach 2", LineTwo = "hill 2", LineThree = "monu 2", LineFour="file2" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 3", LineTwo = "hill 3", LineThree = "monu 3", LineFour="file3" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 4", LineTwo = "hill 4", LineThree = "monu 4", LineFour = "file2" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 5", LineTwo = "hill 5", LineThree = "monu 5", LineFour = "file3" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 6", LineTwo = "hill 6", LineThree = "monu 6", LineFour = "file2" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 7", LineTwo = "hill 7", LineThree = "monu 7", LineFour = "file3" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 8", LineTwo = "hill 8", LineThree = "monu 8", LineFour = "file2" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 9", LineTwo = "hill 9", LineThree = "monu 9", LineFour = "file3" });
this.Items.Add(new ItemViewModel() { LineOne = "beach 10", LineTwo = "hill 10", LineThree = "monu 10", LineFour = "file2" });
this.IsDataLoaded = true;
}
现在的问题是图片没有显示?该怎么办?
答案 0 :(得分:1)
浏览此链接
基本上提供直接url来源不起作用你需要使用转换器。毕竟Source proerty接受了一个Image url,但是将一个位图/图像源对象分配给图像控件
所以基本概念是使用转换器: - )