Table of Contents

Class SvgToBitmapValueConverter

Namespace
SharpVectors.Converters
Assembly
SharpVectors.Converters.Wpf.dll

This implements a value converter that enables the conversion of SVG files to BitmapImage for use with Source binding.

public sealed class SvgToBitmapValueConverter : SvgImageBase, IValueConverter
Inheritance
SvgToBitmapValueConverter
Implements
Inherited Members

Remarks

This converter rasterizes SVG files to bitmap images at a fixed DPI (96 DPI by default), making them suitable for static icons and UI elements. The resulting bitmap is cached after the initial conversion.

The SVG source file can be:

  • From the web (HTTP/HTTPS URLs)
  • From the local computer (relative or absolute paths)
  • From embedded resources (pack:// URIs)
  • Compressed SVG files (.svgz)

XAML Usage:

<Window.Resources>
    <converters:SvgToBitmapValueConverter x:Key="SvgToBitmapConverter" />
</Window.Resources>
<Image Source="{Binding SvgPath, Converter={StaticResource SvgToBitmapConverter}}" />

Constructors

SvgToBitmapValueConverter()

Initializes a new instance of the SvgToBitmapValueConverter class with the default parameters.

Methods

Convert(object, Type, object, CultureInfo)

Converts an SVG file path or URI to a BitmapImage.

ConvertBack(object, Type, object, CultureInfo)

Not implemented for this converter.

ProvideValue(IServiceProvider)

Provides the value for this markup extension.