-1

I am actually an Android developer, I faced the problem of memory exception when I am loading large number of images into a ListBox.

I have no idea about Windows Phone application development so kindly suggest a better solution to load large number of images into ListBox from URL in Windows Phone.

Code is below:

 public class listboxrows
    {
        public string text1 { get; set; }
        public string imageUri { get; set; }
        public string text2 { get; set; }
        public string instID { get; set; }
    }

      <Image Grid.Column="0" Width="90" Height="90" Source="{Binding imageUri}" ></Image>

I want to know if this is a efficient way to load images from url.

If I have huge number of images it will show an memory exception.

Suggest me a better option where I can load any number of images efficiently without any memory exceptions.

Are there any external projects to achieve my goal?

jAC
  • 5,195
  • 6
  • 40
  • 55
madan V
  • 844
  • 3
  • 19
  • 40

2 Answers2

0

While I haven't written actual code to test this, I think the right approach here is to make sure you use data virtualization. This article provides a good example (even though it's discusses Windows Phone 7 development, it's still applicable).

If there truly is a huge amount of data to display you may want to go further and look at the approach in this article that further optimizes the work to display items in a ListBox.

Of course the standard disclaimer is that a UI where the user has to scroll through a very large number of items isn't necessarily always the best approach.

Mats Lannér
  • 1,236
  • 7
  • 6
0

I think this article will help.

  • Never bind server-hosted images directly to the control, because Silverlight runtime will use the UI thread (using WebClient) to fetch that image from the server, that can make the UI unresponsive for some time.

  • Use a background thread and HttpWebRequest class based implementation to download the image data in an efficient way which finally creates BitmapImage and sets that as the source. A clean MVVM wrapper around this would make your entire Image management pretty easy.

Community
  • 1
  • 1
cy198706
  • 569
  • 7
  • 15