String Format Extension in XAML Binding in Silverlight 4


Introduction

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.
 
1.gif 

2.gif

3.gif
 
We can have our custom Date Formatting string too.

4.gif

5.gif
 
 6.gif
 7.gif
 
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 $.

8.gif
 
OR

9.gif 

10.gif
 
Percent Formatting

11.gif
 
OR


 12.gif

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

14.gif

15.gif

Number Formatting

The following predefined options are available for Number Formatting.

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

17.gif

18.gif
 
 
That's it. Try your custom string formatting to explore more about it.

Hope this article helps.

erver'>
Up Next
    Ebook Download
    View all
    Learn
    View all