How is the best way to use .svg images in WPF

VFarkas 30 Reputation points
2024-02-22T12:16:47.8433333+00:00

Hi I tried to use .svg files in Visual Studio with c# and WPF - but an error occurs ...

<Image Source="H:!LKOle2024Desktop!Misc\saanh.svg"/>

This file format is not supported in blend. What is the best way to use .svg files in WPF?

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Azar 29,520 Reputation points MVP Volunteer Moderator
    2024-02-22T13:59:20.26+00:00

    Hey there! VFarkas Thats a great question and thanks for posting it on QandA platform I guess the WPF doesn't support SVG files out of the box, but you can use a handy library called "SvgImageSource" to make it happen. First things first, you'll need to install the "SvgImageSource" package via NuGet.

    xmlns:svg="clr-namespace:SvgImageSource;assembly=SvgImageSource"
    

    Then, in your XAML code, you can simply use the "SvgImage" control

    <svg:SvgImage x:Name="svgImage" Source="YourSvgFile.svg"/>
    
    

    And that's it! If this helps kindly accept the answer thanks much.

    1 person found this answer helpful.

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.