I have a List box in my WP 7 application that contains an image in each item, this list box can have many items , currently when the list box is loaded , all the images are downloaded from the web .
I want to show only the images that are currently visible on screen and other images are loaded only when they are visible (when user scrolls down to those images).
Any ideas how can i do this?
I have a List box in my WP 7 application that contains an image
Share
If you use the ListBox then you can kick off the download only when the item is bound, and then release the image reference by hooking into the CleanUpVirtualizedItem method http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.cleanupvirtualizeditemevent(v=VS.95).aspx
Alternatively take a look at the LongListSelector – it has very nice Linked/Unlinked hooks that notify you when an item is being displayed or no longer being displayed, so that you can unload/load the image dynamically.
Loading images for on-screen display in lists is a fine art – you should do the loading in a background thread, pause downloading when the list is scrolling, etc This blog post is a good start.