Warm tip: This article is reproduced from serverfault.com, please click

Format Date/Time in XAML in Silverlight

发布于 2011-04-07 17:14:17

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 (TimeZone). For instance, today would be displayed as

04/07/2011 at 01:13 p.m. (EST)

Is there a way to do this XAML? Or do I need to build a converter?

Questioner
user687554
Viewed
0
Vlad Bezden 2013-08-21 00:26:41
<TextBlock Text="{Binding Date, StringFormat='{}{0:MM/dd/yyyy a\\t h:mm tt}'}" />

will return you

04/07/2011 at 1:28 PM (-04)