July 10, 2014 Leave a comment
Whether the image resource is embedded in the executable or copied to the output directory, you can reference the image from XAML elements in the same way, by just using the name of the image (assuming that the image is located in the root of the solution).
Below, the “Chico” image has its Build Action set to Resource (embed in executable). The “Groucho” image has its Build Action set to Content (read from output directory).
In XAML, we refer to the images in the same way.
<StackPanel Orientation="Horizontal"> <Image Source="Groucho.jpg" Height="100" Margin="10"/> <Image Source="Chico.jpg" Height="100" Margin="10"/> </StackPanel>
When we run the application, both images are loaded successfully.