Issue displaying a local image from XAML
- by Flack
Hello,
I have the below simple xaml:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Image Source="happyface.jpg"/>
</Grid>
</Window>
happyface.jpg is included in the project and its Build Action is set to "Content" and Copy To Ouptput Directory is set to "Copy Always".
When looking at the app through the VS designer, everything is ok and I see the image. However, when I run the app, no image is displayed. I see the image is copied to the out out directory. If I put in the entire path as the source (C:\SANDBOX\WpfApplication1\WpfApplication1\bin\Debug") it works.
Any ideas as to why the image is not displayed when I run the app? I read about pack URIs but thought that to just simply reference a loose image in the current directory, I can just use the image name.
Thank you.