Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 1.47 KB

bitmapimage_imagefailed.md

File metadata and controls

40 lines (25 loc) · 1.47 KB
-api-id -api-type
E:Windows.UI.Xaml.Media.Imaging.BitmapImage.ImageFailed
winrt event

Windows.UI.Xaml.Media.Imaging.BitmapImage.ImageFailed

-description

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

-xaml-syntax

<BitmapImage ImageFailed="eventhandler"/>

-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");
}

-examples

-see-also

ImageOpened, Image.ImageFailed, ImageBrush.ImageFailed, Image control, Image and ImageBrush