Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hello,

I have some 1000 .jpg images in a folder, Now i want to display these images with image number in a listbox.
For this i have taken a collection of images and set as listbox item source. but the application is very slow as it is loading all the images at a time in to listbox.

so i dont want to load all the images at a time. i want to load 10 images each time and display in the listbox as the user navigates the scroll bar to the end i want to load next images and display.

any one help me How can we load images in to listbox as user scrolls the listbox and display.


Thanks,
Posted
Comments
Sergey Alexandrovich Kryukov 20-Dec-11 1:51am    
How big are the images?
--SA
KiranBabu M 20-Dec-11 2:11am    
Actually these images are the frames of the video. iam extracting the frames of a video and storing as .jpg in a Directory.
After this iam loading these images in to a listbox so that user can select any imagefrom listbox and edit the frame.
Sergey Alexandrovich Kryukov 20-Dec-11 2:02am    
This is an interesting question, a good reason to point out important techniques in design and implementation; I voted 5. (It happens so rarely!)
--SA

Showing one image at a time is usually fast enough, if the image is of the screen size or even more, but 1000 or so… no wonder it's too slow.

You can try few different things. First, you can put only small thumbnail-size images in your list box. I hope you understand: not the images scaled down in the UI, but different images, the copies of bigger images pre-rendered with some small size. Now, show just one big image at a time. Handle the event of selection of an item in the list box and show a big image on the side. Please understand: the users don't need to see more.

Now, even with the thumbnail size, showing all images at a time could be still to much. You can try to "virtualize" the list box through data binding. In this way, it will keep only the number of images not much more than the number visible on a screen at the same time. It needs some thinking, but quite doable. Please see this discussion: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/cd08eb55-650e-4f2e-83dc-b58672c467a4[^].

—SA
 
Share this answer
 
Comments
Amir Mahfoozi 20-Dec-11 2:17am    
+5 complete answer.
Sergey Alexandrovich Kryukov 20-Dec-11 2:20am    
Thank you, Amir.
--SA
KiranBabu M 20-Dec-11 2:42am    
How can we bind only only the number of images not much more than the number visible on a screen to the listbox itemsource and change the binding as user scrolls
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Dec-11 2:21am    
Useful links, especially the article on data virtualization I did not see before. My 5.
--SA
Amir Mahfoozi 20-Dec-11 2:43am    
Thanks :)
KiranBabu M 20-Dec-11 2:37am    
I think virtualizing the Listbox is the solution.
Do we need to implement some logic to only load the no. of images same as the number visible on the listbox. or
setting this properties will take care of that..
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling".
ScrollViewer.IsDeferredScrollingEnabled="True"

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900