Escape Sequences

In some scenarios you may need to include a pair of braces as a literal in your code as a string text. Typically, XAML processors use an open brace ({) to indicate the start of a markup extension sequence. So when the open brace is encountered, the XAML processor assumes that a markup extension follows. To override this behavior and specify an escape sequence, use a pair of empty braces. The two-brace escape sequence ({}) identifies braces in the subsequent text as literal characters.

For example, the following markup shows an escape sequence for an XML namespace that appears at the start of a XAML attribute value:

<StackPanel>
   <TextBlock Text="{}{http://www.contoso.com}" />
</StackPanel>

Here, you want to use the namespace http://www.contoso.com/ ...

Get XAML Developer Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.