1

I trying to add images to my WPF windows but I'm not able to. What I tried to do is to add Source to the Image Xaml and the image does display on the designer, but when I run the program the image is not displayed

    <Image HorizontalAlignment="Left" Height="197" Margin="0,0,0,64" 
VerticalAlignment="Bottom" Width="355" Source="pack://siteoforigin:,,,/Resources/Airplane1.jpg"
 Grid.ColumnSpan="7"/>
John.P
  • 657
  • 2
  • 8
  • 21

1 Answers1

1

Suppose that you put your image at Resources an it's build action Resource, just try to put :

<Image HorizontalAlignment="Left" Height="197" Margin="0,0,0,64" 
VerticalAlignment="Bottom" Width="355" Source="/Resources/Airplane1.jpg"
 Grid.ColumnSpan="7"/>

enter image description here Let me know if it won't work

Moez Rebai
  • 5,094
  • 3
  • 28
  • 47
  • I tried it. I won't work. It was the same problem: The image is shown on the design view but when I run the program the image disappears. – John.P Apr 24 '15 at 08:21
  • Are you sure your build action is Resource – Moez Rebai Apr 24 '15 at 08:23
  • What do you mean by build action? – John.P Apr 24 '15 at 08:25
  • Just select your image and you will find the build action – Moez Rebai Apr 24 '15 at 08:29
  • Thank you it worked. It was set to "none" but now when I set it to Resource it worked :) – John.P Apr 24 '15 at 08:35
  • 1
    @John.P Good to see that your problem was solved, but please [learn about the various build actions](http://stackoverflow.com/questions/145752/what-are-the-various-build-action-settings-in-visual-studio-project-properties) so you know why this solved your issue. – BCdotWEB Apr 24 '15 at 08:58