Hack Forums
[C#] wpf load svg? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] wpf load svg? (/showthread.php?tid=6134519)



wpf load svg? - going clear - Jan 17, 2021

is there any way i can load an svg onto my wpf form? been stuck on this for hours, would really appreciate some help.

im using it to load a logo onto my form, since when i convert it to png it loses a lot of quality


RE: wpf load svg? - Shadow_Cloud - Jan 18, 2021

I've heard good things about SVGImage before, but I've never personally used it:
https://github.com/dotnetprojects/SVGImage


RE: wpf load svg? - Narwin - Jan 18, 2021

Install ShapVectors

Add the namespace :

Code
xmlns:sharpVectors="http://sharpvectors.codeplex.com/svgc/"

Then you have two common ways to use SVG files.

1. Using the library tags.



2. Using the image tag.

Add the namespace :

Code
xmlns:sys="clr-namespace:System;assembly=mscorlib"

Define the resource key in a window or user-control resources



Then



Note: in Svg file properties >
Build Action: Content or Resource

Copy To Output Directory: Copy if newer Or Copy Always.