Felix
Felix

Reputation: 2851

what does the '{}' mean ? StringFormat='{}{0:MM/dd/yyyy}'

I'm new to c# and xaml, but I don't understand the usage of '{}' in the following code:

StringFormat='{}{0:MM/dd/yyyy}'

because I also see code like :

FormatString="MM/dd/yyyy hh:mmtt"

which has no braces.

I'm really confused, is it a c# syntax I am not aware?

Fei

Upvotes: 0

Views: 234

Answers (2)

Vinay Shukla
Vinay Shukla

Reputation: 1844

The escape sequence ({}) is used so that an open brace ({)can be used as a literal character in XAML.

Besides it can also be use to replacing the contents in format string with actual parameters.

In example below they are replaced in a format string with actual arguments, something like:

format ("My name is {1:s}{0:s}", "Diablo", "Pax");

Upvotes: 0

to StackOverflow
to StackOverflow

Reputation: 124746

It's a XAML escape sequence used to prevent the subsequent opening brace from being interpreted as a XAML markup extension.

Upvotes: 1

Related Questions