Issue displaying a local image from XAML
        Posted  
        
            by Flack
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Flack
        
        
        
        Published on 2010-05-27T17:18:55Z
        Indexed on 
            2010/05/27
            17:41 UTC
        
        
        Read the original article
        Hit count: 267
        
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.
© Stack Overflow or respective owner