Click here to Skip to main content
15,882,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to use the SharpVectors package in my project.

This is my XAML.

I get an exception when I run my app: {"Cannot locate resource 'resources/image.svg'."}

This works if I replace the source path with an url.[^]

Question : the "Resources/image.svg" is relative to where ?

Here's an image of my folder structure :

paths - Album on Imgur[^]

<Window x:Class="TestLayout.MainWindow"
                 Title="TestLayout" Height="450" Width="800">

			<RowDefinition Height="50" />
			<RowDefinition Height="*" />

		<StackPanel Grid.Row="1" Orientation="Vertical">
			<Button Margin="10">
				<svgc:SvgViewbox Height="20" Width="20" Source="Resources/image.svg"/>

What I have tried:

I've tried setting the source to :
Updated 2-Jul-21 3:31am
[no name] 3-Jul-21 1:51am    
In my case, I used "/Images/xxx.png" and set my file's "Build Action" to "Content".

(Using "Content" since it proved "smoother" than retrieving embedded images for my scenario)

1 solution

For WPF, relative URIs are references to resources embedded within the current application:
By default, a relative pack URI is considered relative to the location of the markup or code that contains the reference.
Share this answer
Maximilien 5-Jul-21 8:24am    
Thanks Richard, I also needed to change the "Build Action" of the resources in project settings for the file.
TheRealSteveJudge 9-Jul-21 6:34am    
Why only 4*? This answer is worth 5*.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900