This project has moved and is read-only. For the latest updates, please go here.

SVG viewBox (boundaries) is ignored

Topics: Converters and Runtime, SVG
Jun 11, 2013 at 5:04 PM
I am loading an SVG file that has a viewBox property:
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
Here is my code:
        private DrawingImage LoadDrawingImage(string path)
        {
            WpfDrawingSettings settings = new WpfDrawingSettings();
            settings.IncludeRuntime = true;
            FileSvgReader reader = new FileSvgReader(settings);
            DrawingGroup drawing = reader.Read(path);
            return new DrawingImage(drawing);
        }
Then I display the result in WPF Image. The problem is that the displayed image ignores the original SVG view box (boundaries) and stretches the SVG content to the whole available area.

I tried adding a transparent rectangle to my SVG file, but this did not help also:
 <rect fill="none" width="100" height="100"/>
Did I miss something? How can I fix this?