Microsoft documentation states that you can set icons using SVG vector graphics files: https://docs.microsoft.com/en-us/windows/uwp/design/style/icons
However, when I try to use an svg file to set the icon, it just shows blank:
<AppBarButton Label="BitmapIcon">
<AppBarButton.Icon>
<BitmapIcon UriSource="ms-appx:///Svg/MyButton.svg"/>
</AppBarButton.Icon>
</AppBarButton>
This is how I added Svg file to my project: Under project I created a Directory "Svg", and inside of Svg folder I added the file "MyButton.svg". Property of this svg resource file are set to:
BuildAction: content
Copy to Output Directory: Do not copy
Custom Tool:
Custom Tool Namespace:
SVG images can be written directly into the HTML document using the <svg> </svg> tag. To do this, open the SVG image in VS code or your preferred IDE, copy the code, and paste it inside the <body> element in your HTML document. If you did everything correctly, your webpage should look exactly like the demo below.
Export Settings From within Adobe Illustrator select File ⇨ Save As. When the 'Save As' window appears, give your icon a name and change the 'Format' option at the bottom to SVG (svg). Give your icon a descriptive name and set the format as SVG.
You can not use the .svg file as your AppBarButton
Icon directly. To load the SVG icon file into an AppBarButton.Icon, you can convert it to a PNG, font, or path, then use FontIcon, BitmapIcon and PathIcon to display it. More details, you can look into this similar thread:
https://social.msdn.microsoft.com/Forums/en-US/1d32a8b5-a4e1-472b-acce-85c92380b799/uwp-how-to-load-svg-icon-into-appbarbuttonicon?forum=wpdevelop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With