I\'m currently working w/ VS studio 2010, .NET 4.0. Here is my scenario:
I currently have a class library project called \"Images\" that contains a sub folder calle
My image is not in the same project as my window
I solve the problem going to Solution Explorer > "Project name" > Resources then select the image and change Build Action to Resource.
This was driving me crazy. I tried lots of different things based on various articles but nothing worked. My xaml window and image are in a separate DLL from the executable assembly. Not sure if that was part of my problem.
In the end I had success with:
The string visual studio formatted for my image was:
<Image Source="/Paperless.Common;component/Resources/Checkbook.png" />
where "Paperless.Common" was the name of my assembly, and "Checkbook.png" was my image that resided in a "Resources" folder.
It could be as simple as what I just did earlier today. I placed the file in the folder without referencing it in the solution. It showed up fine during design.
The easiest way is to just add the image to your project. Add a Resource folder to your project by right clicking on solution explorer -> Add -> Folder (Name it Resource) -> Right click the newly created Resource folder -> Click Add existing Item -> Find your image (select All Files)
Add an image item to your xaml form selected. Under properties -> Common -> Source you should be able to just drop down and select your image
Selecting from dropdown
1- change the file image properties into resource , {click right on the image file-> choose Properties -> switch Build Action to Resource.
2- use this tag to display image
<Image Source="pack://application:,,,/[Put here the Main Namespace];component/[File path]"/>
example
<Image Source="pack://application:,,,/My;component/Resources/switch-off.png"/>