Reader Level:
Articles

Windows Store Development Tips and Tricks 5 : Content Referencing using URIs

By Ibrahim Ersoy on September 07, 2012
Beginning Windows 8? These tips will help you master it. Trick 5: Content Referencing using URIs
  • 0
  • 0
  • 2838

You have nice images, videos, web pages and other kind of content files in your project.


And you don't know how to reference them dynamically?
 
The given code example will help you load an image dynamically:
 
using Windows.UI.Xaml.Media.Imaging;
image1.Source = new BitmapImage(new Uri("ms-appx:///Assets/welcome.png")); 

As you well know generally we would access a content using BitMapImage with its UriKind parameter.

In XAML based apps,there is no such relative path because every app is deployed as a package.so vs2012 provides us a scheme to access content files in a folder: "ms-appx:///FolderName/contentfile"

You can use ms-appx scheme to access your files dynamically.
  

Ibrahim Ersoy

Ibrahim Ersoy lives in Turkey, Istanbul. He helps running and managing C# Corner. He is a Software Consultant (Sharepoint) and MindCracker MVP. He writes about cutting-edge Microsoft Technologies including XNA,... Read more

Personal Blog: http://www.iersoy.com
COMMENT USING

Trending up