annonymously
annonymously

Reputation: 4708

Event not fired after BitmapImage finishes loading file on hard drive

I am loading an image to be shown on the screen and edited by the user, but I've run into a bit of a problem.

BitmapImage contains an event DownloadCompleted so I tried it, and it never gets fired. I suspect this is because the event only fires if the file is on the internet:

This event may not be raised for all types of bitmap content.

I am rendering the bitmap to a RenderTargetBitmap afterwards, so I can't just set the Image.Source like I would normally.

Is there any way to execute code only after the bitmap is finished loading (from the hard drive)?

EDIT:

I've just tested it a bit and found that the BitmapImage doesn't even start downloading the image until after my initialization method ends.

EDIT:

I've got it working by using the Window.Activated event, but I'm still open to better methods as this method is not such a good one.

Upvotes: 0

Views: 1197

Answers (1)

brunnerh
brunnerh

Reputation: 185290

You can first check if it IsDownloading, if that is false it is loaded, otherwise wait for the event.

Upvotes: 1

Related Questions