I have a couple of Images configured as application resources.
When my application starts, the background of the main window is set via XAML:
I have been trying all the answers here with no success. Here is the simplest way to do it with ms-appx
ImageBrush myBrush = new ImageBrush();
Image image = new Image();
image.Source = new BitmapImage(new Uri(@"ms-appx:///Assets/background.jpg"));
myBrush.ImageSource = image.Source;
TheGrid.Background = myBrush;
Assets folder is in the first level of my project, so make sure to change the path as convenient.