-1

I have a picture in my Resource of a project. Now, which source do I have to set in the image properties? Should I use this one i.e. C:\Users\user\Docs\Project\Resources\image.jpg

(I'm using Visual Studio and have a C# WPF project)

Draken
  • 3,134
  • 13
  • 34
  • 54
Robin
  • 43
  • 1
  • 2
  • 7
  • You cannot assign it as a direct link. Take a look to this [answer](https://stackoverflow.com/questions/5552618/how-to-reference-image-resources-in-xaml) – Rarblack Oct 04 '18 at 07:17

1 Answers1

0

Set the resources buildaction to resource and don't copy to Output Directory

I made a Folder in my Project called Images where i put the Image into

In my code, I put the Picture in a picturebox, so I load it into a BitmapImage

BitmapImage BI = new BitmapImage();
BI.BeginInit();
BI.UriSource = new Uri("pack://application:,,,/Images/ImageName.png");
BI.EndInit();
Shmosi
  • 322
  • 2
  • 17
  • 1
    Shorter: `new BitmapImage(new Uri("pack://application:,,,/Images/ImageName.png"));` No need for Begin/EndInit. – Clemens Oct 04 '18 at 07:37