2013-10-26 122 views
0

這裏我想要顯示動態列表中的圖像,並且圖像是從數據綁定中取得源代碼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

從你在哪裏得到這個圖片?那些在項目中,還是在網上或其他來源? – Namila

回答

1

通過這個鏈接

基本上提供直接鏈接到源不起作用ü需要使用轉換器。畢竟來源proerty接受一個圖片網址,但一個位圖/圖像源對象分配給圖像控制

data binding images

所以基本概念是使用轉換器:-)