Format Date/Time in XAML in Silverlight

前端 未结 5 635
眼角桃花
眼角桃花 2020-12-08 00:02

I have a Silverlight 4 application. I have a C# DateTime object that I\'m binding to my UI. I want this DateTime to be in the format of dd/mm/yyyy time (TimeZon

5条回答
  •  借酒劲吻你
    2020-12-08 00:24

    You can use StringFormat in Silverlight 4 to provide a custom formatting of the value you bind to.

    Dates

    The date formatting has a huge range of options.

    For the DateTime of “April 17, 2004, 1:52:45 PM”

    You can either use a set of standard formats (standard formats)…

    StringFormat=f : “Saturday, April 17, 2004 1:52 PM”
    StringFormat=g : “4/17/2004 1:52 PM”
    StringFormat=m : “April 17”
    StringFormat=y : “April, 2004”
    StringFormat=t : “1:52 PM”
    StringFormat=u : “2004-04-17 13:52:45Z”
    StringFormat=o : “2004-04-17T13:52:45.0000000”
    

    … or you can create your own date formatting using letters (custom formats)

    StringFormat=’MM/dd/yy’ : “04/17/04”
    StringFormat=’MMMM dd, yyyy g’ : “April 17, 2004 A.D.”
    StringFormat=’hh:mm:ss.fff tt’ : “01:52:45.000 PM”
    

提交回复
热议问题