WPF throws "Cannot locate resource" exception when loading the image

In Solution Explorer set the image file's Build Action property to Resource. Then clean the solution and rebuild it.