SvgImageSource.OpenFailed SvgImageSource.OpenFailed SvgImageSource.OpenFailed SvgImageSource.OpenFailed Event


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

public : event TypedEventHandler<SvgImageSource, SvgImageSourceFailedEventArgs> OpenFailed
// Register
event_token OpenFailed(TypedEventHandler<SvgImageSource, SvgImageSourceFailedEventArgs> const& handler) const;

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

// Revoke with event_revoker
OpenFailed_revoker OpenFailed(auto_revoke_t, TypedEventHandler<SvgImageSource, SvgImageSourceFailedEventArgs> const& handler) const;
public event TypedEventHandler<SvgImageSource, SvgImageSourceFailedEventArgs> OpenFailed
Public Event OpenFailed As TypedEventHandler (Of SvgImageSource, SvgImageSourceFailedEventArgs)
<SvgImageSource OpenFailed="eventhandler"/>


You can use the OpenFailed event to determine why the SVG didn't load correctly by checking the SvgImageSourceFailedEventArgs, which contain error information in the Status property. One scenario for handling OpenFailed is to set the UriSource to a different local SVG source file that can serve as a fallback value. For example, if you are trying to display an external image where it's possible that either the source is no longer there, the user has no Internet connection, or the SVG source is not in the correct format, you could set the UriSource to reference a local fallback or placeholder SVG that's part of your app package and is always guaranteed to be available.

private void SvgImageSource_OpenFailed(SvgImageSource sender, SvgImageSourceFailedEventArgs args) {
    if(args.Status != SvgImageSourceLoadStatus.Success) {
        sender.UriSource = new Uri("ms-appx:///Assets/fallback.svg");