Escape the Curly Braces in XAML

If you want to set the value of a property to a string that begins with the open curly brace in XAML , you may want to escape  it in order to avoid it being treated as markup extension.

How to escape the Curly Braces in XAML  ?

You can do this by preceding the string with the empty pair of curly braces. Below is a sample code snippet on how to do it.

<Button Content="{}{This is a developerpublish blog}">
</Button>

image

Alternatively , you can use the property element syntax without escaping the curly braces as shown below.

<Button>
        <Button.Content>
          {This is a developerpublishblog}
        </Button.Content>
</Button>
Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

You cannot copy content of this page