Martin Suchan – BloQ Random #WPdev stuff

31May/133

Image path databinding in WP8 and Windows 8 apps

I don't like lengthy articles, so let's make it short and easy.
When you are developing Windows Phone 8 or Windows 8 "modern" apps, you surely want to display images in it.
For displaying images the well known Image element is used:

<Image Source="imagepath"/>

The imagepath can have multiple values, it can be:

  • Uri address to image located on the Internet
  • path to image located in app resources/app installation package
  • path to image located in app isolated storage

The interesting point is that I've discovered only today that it is actually possible in WP8 apps to display images located in isolated storage directly just by defining the Source, without any loading to Stream and BitmapSource. That's right, even if you search on StackOverflow or on MSDNĀ  how to display images located in isolated storage using path in WP8, they tell you it's not possible.

Yes, it is possible, and the whole magic it so use absolute image path using the StorageFile.Path property. Now you know the secret, but let's check it in detail.