This post is for people writing “Metro Style Apps”, or apps built for Windows 8 who are trying to set the source of an image within their WPF project. It should be easy to do this but it is surprisingly tricky and took me 1.5 hours to figure out. Here’s the code:
And here’s why it’s such a pain: WinRT applications need the full path to an image, they do not accept relative paths. The full path is confusing, but you can get at it if you’re in a class that extends FrameworkElement (basically any UI element) via the BaseUri property. Totally not obvious and not easy to discover!