Escaping curly braces in XAML code
December 30, 2009 Leave a Comment
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:"