WinRT–Set an Image Source to an Asset via XAML / Set a tiled background


I needed a quick example of how to set an ImageSource via XAML to an image that was in my project but I was failing to get the syntax correct (still transitioning from WP7 syntax). Anyway for reference, here was the XAML that I ended up using:

ImageSource="ms-appx:///Assets/Wood.png"

I had found a great blog post at http://www.robfe.com/2012/07/creating-tiled-backgrounds-in-metro-style-xaml-apps/#comments that gave an example of how to tile an image over the background in a WinRT application. After creating an assembly with the TileCanvas class in it and then referencing it from my project, I was able to use this XAML in my MainPage to show a form with a tiled background:

TileCanvas Declartion

xmlns:tile="using:Argus.WinRt.UI.TileCanvas"

TileCanvas Usage:

<tile:tilecanvas imagesource="ms-appx:///Assets/Wood.png"></tile:tilecanvas>

Since I didn’t write the code for the TileCanvas class I’m not going to paste it here but I will include links to the source.