Getting the URI in Silverlight

We may need the uri of the silverlight app in various circumstances (like if we move the app around in the solution, or are dealing with images and other resources located in a folder on the web site that's not part of the silverlight project). We can get the path easily with:

App.Current.Host.Source

So, if we are to get a uri to an image in the Images folder in the web site that hosts the silverlight app, we can go:

var uri = new Uri(App.Current.Host.Source, "../Images/somepic.jpg");

Hope that helps.

2 Comments

Comments have been disabled for this content.