SvgImageSource SvgImageSource SvgImageSource SvgImageSource Class


Provides a source object for properties that use a Scalable Vector Graphics (SVG) source. You can define a SvgImageSource by using a Uniform Resource Identifier (URI) that references a SVG file, or by calling SetSourceAsync(IRandomAccessStream) and supplying a stream.

public : class SvgImageSource : ImageSource, ISvgImageSource
struct winrt::Windows::UI::Xaml::Media::Imaging::SvgImageSource : ImageSource, ISvgImageSource
public class SvgImageSource : ImageSource, ISvgImageSource
Public Class SvgImageSource Inherits ImageSource Implements ISvgImageSource
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)



SvgImageSource lets you use a SVG source to be displayed using an ImageBrush or directly in an Image control. SvgImageSource supports secure static mode from the SVG specification and does not support animations or interactions. The Direct2D API supplies the underlying SVG rendering support and for more info on specific SVG element and attribute support, see SVG Support. For more info on formats and how to use Uniform Resource Identifier (URI) to access image source files that come from app resources, see Image and ImageBrush.

The SvgImageSource represents an abstraction so that a SVG source can be set asynchronously but still be referenced in XAML markup as a property value, or in code as an object that doesn't use awaitable syntax. When you create a SvgImageSource object in code, it initially has no valid source. You should then set its source using one of these techniques:

  • Use the SvgImageSource(Uri) constructor rather than the default constructor. Although it's a constructor, you can think of this as having an implicit asynchronous behavior: the SvgImageSource( won't be ready for use until it raises an Opened event that indicates a successful async source set operation.
  • Set the UriSource property. As with the Uri constructor, this action is implicitly asynchronous, and the SvgImageSource won't be ready for use until it raises an Opened event.
  • Use SetSourceAsync(IRandomAccessStream). This method is explicitly asynchronous. The properties where you might use a SvgImageSource, such as Source, are designed for this asynchronous behavior, and won't throw exceptions if they are set using a SvgImageSource that doesn't have a complete source yet. Rather than handling exceptions, you should handle Opened or OpenFailed events either on the SvgImageSource directly or on the control that uses the source (if those events are available on the control class).

Opened and OpenFailed are mutually exclusive. One event or the other will always be raised whenever a SvgImageSource object has its source value set or reset.


Depending on your intended use case, you can specify the size of a SvgImageSource in several different ways:

  • Use the RasterizePixelHeight and RasterizePixelWidth properties to specify an explicit height and width in logical pixels to decode the SVG source at.
  • If you don't specify a RasterizePixelHeight or RasterizePixelWidth, then the application's layout will dictate the decode size while still preserving aspect ratio. If no size can be determined from the application's layout, then the SVG source will be decoded to the maximum window size.

Version compatibility

The SvgImageSource class is not available prior to Windows 10, version 1703. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you will not be able to use SvgImageSource. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this class before you use it.


Here's an example of how to set the source of an Image to a SVG file. Since there is no height or width explicitly specified, the application layout will dictate the appropriate size for the SVG to decode at.

<Image Source="Assets/mysvg.svg"/>


SvgImageSource() SvgImageSource() SvgImageSource() SvgImageSource()

Initializes a new instance of the SvgImageSource class.

SvgImageSource(Uri) SvgImageSource(Uri) SvgImageSource(Uri) SvgImageSource(Uri)

Initializes a new instance of the SvgImageSource class, using the supplied Uniform Resource Identifier (URI).


Dispatcher Dispatcher Dispatcher Dispatcher

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

(Inherited from DependencyObject)
RasterizePixelHeight RasterizePixelHeight RasterizePixelHeight RasterizePixelHeight

Gets or sets the height to use for SVG rasterization operations.

RasterizePixelHeightProperty RasterizePixelHeightProperty RasterizePixelHeightProperty RasterizePixelHeightProperty

Identifies the RasterizePixelHeight dependency property.

RasterizePixelWidth RasterizePixelWidth RasterizePixelWidth RasterizePixelWidth

Gets or sets the width to use for SVG rasterization operations.

RasterizePixelWidthProperty RasterizePixelWidthProperty RasterizePixelWidthProperty RasterizePixelWidthProperty

Identifies the RasterizePixelWidth dependency property.

UriSource UriSource UriSource UriSource

Gets or sets the Uniform Resource Identifier (URI) of the SVG source file that generated this SvgImageSource.

UriSourceProperty UriSourceProperty UriSourceProperty UriSourceProperty

Identifies the UriSource dependency property.


ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)
GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)
GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)
ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)
SetSourceAsync(IRandomAccessStream) SetSourceAsync(IRandomAccessStream) SetSourceAsync(IRandomAccessStream) SetSourceAsync(IRandomAccessStream)

Sets the source SVG for a SvgImageSource by accessing a stream and processing the result asynchronously.

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)


Opened Opened Opened Opened

Occurs when the SVG source is downloaded and decoded with no failure.

OpenFailed OpenFailed OpenFailed OpenFailed

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