tags:

views:

785

answers:

1

There is a slight delay from setting the Source of the image control to the actual displaying.

I need some way to find out when exactly the Image is displayed but I can't seem to find any events that I can hook into. Does anybody have a way to detect this?

A: 

Assuming your image is some sort of bitmap, Create a BitmapImage object and use its DownloadCompleted event.

Examples, call ReadyToDisplay when the image is ready:

from code:

BitmapImage bmp = new BitmapImage(imageUri);
bmp.DownloadCompleted += ReadyToDisplay;
image.Source = bmp;

from XAML:

<Image>
   <Image.Source>
      <BitmapImage UriSource="/images/image.png" DownloadCompleted="ReadyToDisplay"/>
   </Image.Source>
</Image>

I didn't test those code samples, so they might have typos

Nir
Thanks for the answer, but for some reason the event is not fired for locally loaded images. A Google also reveals that this event is not reliable. For me it the event does not fire at all.
Kwan Cheng