2012-12-31 31 views
0

我有一個圖像列表,我需要將圖像綁定到列表視圖中的圖像控制器。將圖像綁定到地鐵應用程序中的ListView(贏8應用程序)

我的XAML代碼

<ListView Name="lbxItems" SelectionChanged="ListBox_SelectionChanged_1" ItemsSource="{Binding Srcimg}"> 
           <StackPanel> 
          <Image Name="item" Height="113" Source="{Binding}" Stretch="None"/> 
           </StackPanel> 
        </ListView> 

代碼文件

public void BindImgs() 
     { 
     //Some code here 

      AClass a=new AClass(); 
      foreach (var photo in Photos) 
      { 
       Uri uri = new Uri(photo.ToString(), UriKind.Absolute); 
       a.Srcimg.Add(uri); 
      } 
      lbxItems.DataContext =a; 
     } 

    public class AClass 
     { 
      private List<Uri> _srcimg = new List<Uri>(); 

      public List<Uri> Srcimg 
      { 
       get { return _srcimg; } 
      } 
     } 

背後,當我運行的應用程序,它只是顯示了URI路徑字符串,而不是顯示圖像。請幫忙!

回答

0

更改您的XAML來此,你應該有更多的運氣:-)

<ListView ItemsSource="{Binding Srcimg}"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
      <Image Height="113" Source="{Binding}" Stretch="None"/> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
</ListView> 
+0

嘿它works.Thank你了... :) – Hasantha

相關問題