2016-04-27 107 views
0

我想下載從指定的URI的靜像,並顯示在網格視圖下載圖像8.1

<GridView> 
    <GridView.ItemTemplate> 
     <DataTemplate> 
      <Image Width="150" Height="150" Source="{Binding Source={}}"/> 
     </DataTemplate> 
    </GridView.ItemTemplate> 
</GridView> 
+0

使用'Uri'下載圖像,並將其設置爲'從代碼的'Image'標籤ImageSource'財產背後 –

+0

你有搜索這http://stackoverflow.com/questions/33854553/create- imagebrush-bitmap-and-writeablebitmap-from-an-url? – JTIM

回答

0

如果你有一個模型類,將其綁定以下屬性&設置爲圖像元素。

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>