BitmapImage.ImageOpened BitmapImage.ImageOpened BitmapImage.ImageOpened BitmapImage.ImageOpened Event


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.

public : event RoutedEventHandler ImageOpened
// Register
event_token ImageOpened(RoutedEventHandler const& handler) const;

// Revoke with event_token
void ImageOpened(event_token const& cookie) const;

// Revoke with event_revoker
ImageOpened_revoker ImageOpened(auto_revoker_t, RoutedEventHandler const& handler) const;
public event RoutedEventHandler ImageOpened
Public Event RoutedEventHandler ImageOpened
<BitmapImage ImageOpened="eventhandler"/>


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.

See Also