public partial class MainWindow : Window
{
public List<Picture> Pictures { get; set; }
public MainWindow()
{
InitializeComponent();
Pictures = new List<Picture>()
{
new Picture("https://images.askmen.com/1080x540/2017/01/06-044621-the_pitfalls_of_dating_a_married_woman.jpg", "Girl 1"),
new Picture("https://images.pexels.com/photos/733872/pexels-photo-733872.jpeg?cs=srgb&dl=beautiful-blur-blurred-background-733872.jpg&fm=jpg", "Girl 2")
};
DataGrid.ItemsSource = Pictures;
}
}
图片模型
public class Picture
{
public Picture(string path, string name)
{
Path = path;
Name = name;
}
public string Path { get; set; }
public string Name { get; set; }
}
1条答案
按热度按时间vybvopom1#
你需要一个
model
和一个DataGridTemplateColumn
然后这样做:主窗口.cs
图片模型