Image not displaying in C# WPF
In your project:
- Create a folder say "img", right click on it and select add existing item add image to folder
- Go to properties of the added image, set
Build Action
asResource
andCopy To Output Directory
asCopy if newer
.
It worked for me.
In XAML
<Image HorizontalAlignment="Left" Name="MyImg" Height="80" Margin="273,147,0,0"
VerticalAlignment="Top" Width="100" Source="/img/Desert.jpg"/>
Go to the properties for the image in Visual Studio and change "Build Action" to "Resource" and "Copy to Output Directory" to "Copy if newer".
I had to do a rebuild, but then it worked. Cred to swapnil.