Project Description

Svg2Xaml is a stand-alone library without using third-party libraries like SvgReader, XamlTune or SVG#. Its main purpose is to load SVG files at runtime, the converted WPF object can be saved using XamlWriter to create XAML files though.

Svg2XamlTest_1.PNGSvg2XamlTest_2.PNGSvg2XamlTest_3.PNGSvg2XamlTest_4.PNG
The screenshots show some icons from the Oxygen Icon Theme (http://www.oxygen-icons.org/); these icons are currently only available via SVN: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/oxygen-icons/scalable.

Usage

Svg2Xaml provides the static class SvgReader which is similar to XamlReader; SvgReader provides some static Load overloads loading an SVG file either from a Stream or from an XamlReader and returning a DrawingImage with the content of the rendered SVG document:

using(FileStream stream = new FileStream(FileName, FileMode.Open, FileAccess.Read))
{
  DrawingImage image = SvgReader.Load(stream);

  // SvgReaderOptions options = new SvgReaderOptions(...);
  // DrawingImage image = SvgReader.Load(stream, options);
}


Further more you may use the SvgImage markup extension:

<!-- xmlns:svg2xaml="clr-namespace:Svg2Xaml;assembly=Svg2Xaml" -->
<Image Source="{svg2xaml:SvgImage test.svg}"/>

Svg2XamlBrowser

I have added a small utility to browse for SVG files. SVG files causing errors, are displayed as red squares. Double clicking a thumbnail will open a preview window where you can see the SVG image, its source and the serialized XAML.

Svg2XamlBrowser_1.pngSvg2XamlBrowser_2.png
(FilterEffects within the SVG files are ignored within the browser)

Any help is appreciated!

Last edited Sep 18, 2011 at 11:44 PM by boris_richter, version 23