Click here to Skip to main content
14,216,449 members
Rate this:
Please Sign up or sign in to vote.
See more:
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,
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

Why is it that no-one is capable of using google, or the search built in to code project ?

Custom ListBox Layout in WPF[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

//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;
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100