The static method Application.GetResourceStream provides an easy way of accessing a resource using its relative URI. It returns a StreamResourceInfo object. The Stream property of the StreamResourceInfo object provides access to the actual binary data, which has been set as the image source property by converting it to an instance of BitmapImage.
For the Application.GetResourceStream method to work, the resource must be marked as a Resource in Build Action.
If the resource has been marked as Content in the Build Action property, then the Application.GetContentStream method should be used to get the resource stream.