Jaa


BitmapImage.ImageOpened Event

Definition

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.

// Register
event_token ImageOpened(RoutedEventHandler const& handler) const;

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

// Revoke with event_revoker
BitmapImage::ImageOpened_revoker ImageOpened(auto_revoke_t, RoutedEventHandler const& handler) const;
public event RoutedEventHandler ImageOpened;
function onImageOpened(eventArgs) { /* Your code */ }
bitmapImage.addEventListener("imageopened", onImageOpened);
bitmapImage.removeEventListener("imageopened", onImageOpened);
- or -
bitmapImage.onimageopened = onImageOpened;
Public Custom Event ImageOpened As RoutedEventHandler 
<BitmapImage ImageOpened="eventhandler"/>

Event Type

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.

Applies to

See also