Search code examples
c#wpfimagexamlimagesource

How to find out relative path of image


In a legacy project there are absolute path to the images, for example:

C:/projects/LegacyProject/Project/Client/UserInterface/Images/arrow.png

Now I want to use relative path, so that every developer can use that project, no matter where he has his copy of the sourcecode.

Is there an easy way to find out the (Resource) relative path? How can I use it then?

At the moment I have for example:

<Image Source="C:/projects/LegacyProject/Project/Client/UserInterface/Images/arrow.png" Stretch="Fill" />

What I want is something like:

<Image Source="arrow.png" Stretch="Fill" />

Tried around with

<Image Source="pack:,,, arrow.png" Stretch="Fill" />
<Image Source="/WPF1;arrow.png"></Image> 

and similar things


Solution

  • Add image using Source property of the Image control by clicking

    enter image description here

    then the path will be something like this:

    /[project name];component/[folder name: e.g. Images]/[file name]