How to get the path where is the silverlight xap file is served

In case you are developing a silverlight application that contains images. You can set the build action of these images to Embedded Resource so as to have them within your XAP file and hence reference them relatively. However, in case you do not want to do so, you can still reference your images easily by setting their passes relative to the current path of the XAP file. The line of code below gets the current path of the running XAP file.



Escaping curly braces in XAML code

Sometimes you want your user interface text contains a curly brace “{“. Unfortunately, the xaml parser will consider it as markup extension and will refuse to compile. For example, the below code will not compile and will give an error: The given key was not present in the dictionary.

TextBlock Text="{Username:"

In order to escape the curly brace, you need to add “{}” before your text brace as shown below:

TextBlock Text="{}{Username:"