String Format Extension In XAML Binding In Silverlight 4


In Silverlight 4, an extension property called StringFormat is added to display formatting display. There are some predefined formats available. In this article we will see some of them.

Date Formatting

The following are the predefined Date Formatting options available. We can use the shortcuts such as {0:D} to display respectively.

We can have our custom Date Formatting string too.

Currency Formatting

Based on the regional settings of the Operating System, the Currency format is taken. By default when you don’t change its US $.


Percent Formatting


If you need single decimal point formatting, you can try the following.

Number Formatting

The following predefined options are available for Number Formatting.

You can try the above or format your own custom format such as following.

That’s it. Try your custom string formatting to explore more about it.

Hope this article helps.