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

Posted by Blake on 9/4/2012

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:


I had found a great blog post at 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


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.