Since the creators update came out, uwp can use svg images as briefly explained here (minute 3).
I have this svg (48x48) and i can use it fine, if (and only if) i set the image's width&height to 48 and the strech to none:
<Image Source="ms-appx:///Assets//check.svg" Height="48" Width="48" Stretch="None"/>
If i set the stretch to fill, the image disappears. If i increase the width and height i can see that the icon is pinned to the upper left corner of the image (screenshot with a different svg but same size). Isn't Stretch=Fill and a fixed height/width the intended way to scale an image?
It looks to my as if the stretching algorithm does not grasp that my svg is supposed to be 48x48. Am i doing it wrong, or are there workarounds?
For me it works only if you set
RasterizePixelHeight
andRasterizePixelWidth
to the svg original resolution (e.g. document properties in Inkscape).I've been having the same issue all morning and was about to completely give up on Svg support, seems mad that you can't get a scalable format to scale properly...
But, I had one more go and I think I've worked this out.
It seems that you need to tell the
SvgImageSource
to rasterize at the SVG's original design size and then get theImage
to scale it. Not sure it's a particularly helpful approach, but certainly solves it as of build 15063.So if the SVG was 48x48 we turn it into a bitmap at 48x48 using the
RasterizePixelHeight
andRasterizePixelWidth
values and then the image scales that to 24x24.Hope that helps.
Update I just re-read your question and realised that you were looking to increase the scale whereas I've been working to decrease it. Looks as though the technique still works, but as you scale up you're going to lose any sharpness of image due to the bitmap scale process. I think this points to a fundamental flaw in the current implementation. They seem to be rendering the svg as a bitmap, and we have to tell it the original size to get it to render properly, and then they allow the bitmap code to do the rest of the work.
I think it's somewhat debateable whether this is true support or an odd half way house. Somewhere someone suggested that Adobe Illustrator can generate XAML paths, I think I'm going to look at that to see whether I can get a better quality output, shame though because I really like Inkscape :-(
For me it worked without setting those Properties, but adding
preserveAspectRatio="xMinYMin"
to the<svg ...>
tag and deletingwidth
andheight
from the<svg ...>
tag.For me, it worked with modifying SVG file like this:
preserveAspectRatio
property tosvg
tag. For me it was"xMinYMin meet"
.viewbox
property ofsvg
tag to this template "0 0 ActualHeight ActualWidth", in my case it was"0 0 1050 805"
.height
andwidth
ofsvg
tag to"auto"
. Now svg element is relative toHeight
,Width
andStretch
properties you provide in your XAML page or view.SVG File:
XAML File: