Javier Aranda
Javier Aranda

Reputation: 33

Why my SVG file is not displayin as source of my Image tag in UWP/XAML?

I'm developing a UWP app on visual studio, and learning through the process. I'm having a problem with the icons of the navbar and svg files. First I tried my custom icons as PNG files, there was no problem, the icons were displaying correctly. Then I decided to use SVG for quality porpuses and create the same icon as SVG from a PNG file. But for some reason it is not displaying at all.

This is my XAML:

<NavigationViewItem Name="AdminTest" Tag="Profile">
                    <NavigationViewItem.Content>
                        <StackPanel Orientation="Horizontal" Margin="-15,0,0,0">
                            <Image Source="/Assets/test.svg" Width="40" Height="20
                                  "/>
                            <TextBlock TextAlignment="Center" Text="AdminTest"/>
                        </StackPanel>
                    </NavigationViewItem.Content>
</NavigationViewItem >

And this is were the icon is supossed to be:

Navbar pic

The svg is added in my solution and before when it was a png it worked fine, any idea what im doing wrong?

Upvotes: 0

Views: 1806

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32785

Why my SVG file is not displayin as source of my Image tag in UWP/XAML?

The problem is your svg image has specific width and height property. please edit your svg image content and find width and height property and delete them.

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   id="svg4236"
   version="1.1"
   inkscape:version="0.91 r13725" 
   height="200" //delete height
   width="200"  //delete width
   viewBox="0 0 200 200"
   sodipodi:docname="MallowNinebark.svg">
  <metadata

Upvotes: 1

Related Questions