c# - Proper way to load listbox with images -


i have scenario have list box images. have loaded images in list box,but list box loading slowly.

i want faster way load listbox. again when loading list box second time slows down app. there way store images somewhere in isolated storage or anywhere, when loaded second time can loaded fastly.

as whole want faster way load list box images. here code:

public mainpage() {     initializecomponent();     getimages();  } public void getimages() {     try     {         medialibrary medialibrary = new medialibrary();         var pictures = medialibrary.pictures;         foreach (var picture in pictures)         {             bitmapimage image = new bitmapimage();             image.setsource(picture.getimage());//out of memory exception             img mediaimage = new img();             mediaimage.imgs = image;             imagelist.items.add(mediaimage);         }     }     catch (exception ex)     {      }  } public class img {     public img()     { }     public bitmapimage imgs { get; set; } } 

in xaml...

<scrollviewer name="sc" horizontalscrollbarvisibility="auto" verticalscrollbarvisibility="hidden" margin="0,422,0,43">         <listbox name="imagelist" selectionchanged="imagelist_selectionchanged_1" height="126">             <listbox.itemspanel>                 <itemspaneltemplate >                     <stackpanel orientation="horizontal"></stackpanel>                 </itemspaneltemplate>             </listbox.itemspanel>             <listbox.itemtemplate>                 <datatemplate >                     <stackpanel orientation="horizontal">                     <image margin="10" name="image1" source="{binding imgs}" height="150" width="150"></image>                         </stackpanel>                 </datatemplate>             </listbox.itemtemplate>         </listbox>     </scrollviewer> 
  1. so please tell me how load images fastly.
  2. also loading page second time or clickling button, in getimages() method in picture.getimage() showing outofoemoryexception(i have written in code).


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -