Wednesday, April 9, 2008

XAML Tip - How do I escape curly braces?

Ever wondered how you would get a TextBlock to display some text with the curly braces? For example, say you wanted to display the text {Hello}. If you just say, <TextBlock Text="{Hello}"/> you will not get the desired result since the parser will assume that it is a markup extension.

This is what you should do to trick the parser: <TextBlock Text="{}{Hello}"/>

Simple, eh?

3 comments:

Anonymous said...

Hey, buddy
Can you tell me how you found this fabulous tricky tip?

Anonymous said...

http://msdn.microsoft.com/en-us/library/ms744986.aspx

Anonymous said...

Thanks for that!