Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 2.05 KB

bitmapimage_imageopened.md

File metadata and controls

30 lines (21 loc) · 2.05 KB
-api-id -api-type
E:Microsoft.UI.Xaml.Media.Imaging.BitmapImage.ImageOpened
winrt event

Microsoft.UI.Xaml.Media.Imaging.BitmapImage.ImageOpened

-description

Occurs when the image source is downloaded and decoded with no failure. You can use this event to determine the size of an image before rendering it.

-xaml-syntax

<BitmapImage ImageOpened="eventhandler"/>

-remarks

When ImageOpened fires, that serves as the notification that any asynchronous operations have completed and all the properties of a BitmapImage are ready for use. For example, to determine the size of the image before rendering it, handle ImageOpened, and check the value of the PixelWidth and PixelHeight properties on the BitmapImage that fired the event. The event data for the ImageOpened event isn't typically useful.

The Image class also has an ImageOpened event (as does ImageBrush). For the other ImageOpened events, these fire at a time when the image has probably already rendered. The BitmapImage.ImageOpened fires at a time that is potentially before you've assigned your BitmapImage to be the source of an Image or ImageBrush. If you want to change properties that affect rendering of the image based on reading properties of the BitmapImage, it's often best to handle the underlying BitmapImage's event prior to assigning it as a source.

-examples

-see-also

ImageFailed, Image control, Image and ImageBrush