BitmapImage.ImageFailed event

Applies to Windows and Windows Phone

Occurs when there is an error associated with image retrieval or format.

Syntax


public event ExceptionRoutedEventHandler ImageFailed


<BitmapImage ImageFailed="eventhandler"/>

Event information

Delegate ExceptionRoutedEventHandler

Remarks

One scenario for handling ImageFailed is to set the UriSource to a different local image file that can serve as a fallback value. For example, if you are trying to display an external image where it's possible that the source is no longer there, or for when the user has no Internet connection, you could set the UriSource to reference a local fallback or placeholder image that's part of your app package and is always guaranteed to be available.


private void BitmapImage_ImageFailed(object sender, ExceptionRoutedEventArgs e) {
    BitmapImage bitmapImage = sender as BitmapImage;
    bitmapImage.UriSource = new Uri("ms-appx:///Images/fallback.png");
}

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Media.Imaging
Windows::UI::Xaml::Media::Imaging [C++]

Metadata

Windows.winmd

See also

BitmapImage
ImageOpened
Image.ImageFailed
ImageBrush.ImageFailed
Image control
Quickstart: Image and ImageBrush

 

 

Show:
© 2014 Microsoft