将多个图像加载到wpf中的列表框中 [英] Loading multiple images in to listbox in wpf
本文介绍了将多个图像加载到wpf中的列表框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
Plz ny one指导我如何将多个图像加载到WPf中的列表框中。
i有Wpf窗口中的列表框和按钮以及sepearate文件夹中的图像。如果我们点击按钮,所有图像都应显示在列表框中。
PLZ任何人都可以帮助我完成此任务。
谢谢,
Hi
Plz ny one guide me how to load multiple images in to a listbox in WPf.
i have a listbox and a button on the Wpf window and images in a sepearate folder. if we click on the button all the images should display in the listbox.
plz any one help me to accomplish this.
Thanks,
推荐答案
为什么没有人能够使用谷歌或内置的搜索代码项目?
WPF中的自定义列表框布局 [ ^ ]
Why is it that no-one is capable of using google, or the search built in to code project ?
Custom ListBox Layout in WPF[^]
/ /从预定位置加载BMP图像
private void LoadImages()
{
//开始清洁
listView1.Clear();
listView1.Refresh();
imageList1.Images.Clear();
//设置清单
imageList1.ImageSize = new尺寸(50,50);
imageList1.ColorDepth = ColorDepth.Depth32Bit;
imageList1.TransparentColor = Color.White;
//获取位置
string [] images = Directory.GetFiles(_path,*+ _imageFileExtension);
//加载列表图片列表
foreach(图片中的字符串img)
{
System.Drawing.Image img1 = System.Drawing.Image.FromFile(img);
imageList1.Images.Add(GetThumbnaiImage(imageList1.ImageSize.Width,img1));
}
//填充列表查看
int j = 0;
foreach(图片中的字符串img)
{
FileInfo fi = new FileInfo(img);
this.listView1.Items.Add(fi.Name);
this.listView1.Items [j] .ImageIndex = j ;
j ++;
}
//显示清单
this .listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList1;
}
//Load BMP images from a pre-defined location
private void LoadImages()
{
//start clean
listView1.Clear();
listView1.Refresh();
imageList1.Images.Clear();
//setup the list
imageList1.ImageSize = new Size(50, 50);
imageList1.ColorDepth = ColorDepth.Depth32Bit;
imageList1.TransparentColor = Color.White;
//get the location
string[] images = Directory.GetFiles(_path, "*" + _imageFileExtension);
//load the list image list
foreach (string img in images)
{
System.Drawing.Image img1 = System.Drawing.Image.FromFile(img);
imageList1.Images.Add(GetThumbnaiImage(imageList1.ImageSize.Width, img1));
}
//populate the list view
int j = 0;
foreach (string img in images)
{
FileInfo fi = new FileInfo(img);
this.listView1.Items.Add(fi.Name);
this.listView1.Items[j].ImageIndex = j;
j++;
}
//display the list
this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList1;
}
这篇关于将多个图像加载到wpf中的列表框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文