#1,110 – Using a Resource as a Content File
July 9, 2014 2 Comments
When your application needs to use a resource (e.g. an image), it can embed the resource in the executable for the application. You can then access the resource at run time using a Uri like the one shown below.
BitmapImage bmi = new BitmapImage(new Uri("pack://application:,,,/Ted.jpg"));
You can also include an image in your project and then cause the image to be placed in an output directory along with the executable, but not embedded within it. You do this by setting its Build Action to Content and by setting the Copy to Output Directory property.
In this case, after building the project, the .jpg file is copied to the output directory.
At run time, you can use exactly the same Uri to access the file, although it is external to the application, rather than embedded.