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>
- so please tell me how load images fastly.
- also loading page second time or clickling button, in
getimages()
method inpicture.getimage()
showingoutofoemoryexception
(i have written in code).
Comments
Post a Comment