【发布时间】:2021-08-07 12:41:09
【问题描述】:
您好 stackoverflow 专家, 最近只有我开始在 WPF 中编码并卡在某个地方。 我必须显示图像列表和文本,我试图在谷歌上找到但像往常一样都使用硬编码值。
第 1 步:在 XAML 文件中,我使用了包装面板,代码如下:
<ListView Width="auto" Name="listviewSource" BorderBrush="{x:Null}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="auto" Height="150" Orientation="Vertical" UseLayoutRounding="True" / >
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
第2步:目前我可以成功绑定所有图片,代码:
Image imageData = new Image();
List<Image> ImageList = new List<Image>(); // List of Image
List<string> imageName = new List<string>(); // list of name
imageData = bitmapData // here bitmapData is having data which is already computed
imageName.Add(name); // This is the issue, how to display name below image
ImageList.Add(imageData );
listviewSource.ItemSource = ImageList;
【问题讨论】:
标签: c# wpf windows winforms listview