Subcreation
Subcreation

Reputation: 1353

Displaying loading progress for Image control in WP7

How do I get loading progress with the percent loaded info when an image is loading?

I have this:

Image image  = new Image();
image.Source = new BitmapImage(new Uri("http://somesite.com/someimage.jpg"));

I expected something like this:

image.Loading += RoutedEventHandler(image_Loading);

but I can't find any such event. There is Loaded (not related to loading the source) and ImageOpened (which fires after loading the source is complete and has effected a layout pass).

I know it is possible because I have seen other apps indicate loading progress for images (for example "img news reader"). Is this possible with the standard Image Control, is there a 3rd party control that provides this, or do I have to write my own?

Upvotes: 4

Views: 2138

Answers (1)

Subcreation
Subcreation

Reputation: 1353

DownloadProgress is the event I was looking for, and it was hiding in the BitmapImage class:

Image image = new Image();
BitmapImage myBitmap = new BitmapImage(new Uri("http://somesite.com/someimage.jpg", UriKind.Absolute));
myBitmap.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(myBitmap_DownloadProgress);

image.Source = myBitmap;

Upvotes: 3

Related Questions