如果你有一個模型類,將其綁定以下屬性&設置爲圖像元素。
Public class YourClass
{
public string imageuri { get ; set ; } //web image uri
public BitmapImage ImageUrl
{
get
{
if (!string.IsNullOrEmpty(imageuri))
{
BitmapImage bmi = new BitmapImage();
bmi.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bmi.UriSource = new Uri(imageuri, UriKind.Absolute);
return bmi;
}
return null;
}
}
}
<GridView>
<GridView.ItemTemplate>
<DataTemplate>
<Image Width="150" Height="150" Source="{Binding ImageUrl,Mode=Twoway}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
使用'Uri'下載圖像,並將其設置爲'從代碼的'Image'標籤ImageSource'財產背後 –
你有搜索這http://stackoverflow.com/questions/33854553/create- imagebrush-bitmap-and-writeablebitmap-from-an-url? – JTIM