Search code examples
c#silverlightxaml

Format Date/Time in XAML in Silverlight


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?


Solution

  • <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)