<ListView Name="listView" ItemsSource="{Binding}" Background="WhiteSmoke">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding title}"></TextBlock>
<Image Width="90" Height="90" Source="{Binding picUrl}"></Image>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
public MainPage()
{
this.InitializeComponent();
listView. DataContext = listData ;//设置DataContext
}
ObservableCollection<data> listData = new ObservableCollection<data>();
void bindData() {
listData.Add(new data() { title = "ttttt1", picUrl = "http://www.songshizhao.com/editor/attached/image/20170416/123.jpg20170416115527_9528.jpg" });
listData.Add(new data() { title = "ttttt1", picUrl = "http://www.songshizhao.com/editor/attached/image/20170416/123.jpg20170416115527_9528.jpg" });
listView.ItemsSource = listData;
}
public class data {
public string title { get; set; }
public string picUrl { get; set; }
}