Monday, August 27, 2012

DateTime Formatting in Silverlight XAML

DateTime Formatting in Silverlight XAML

I have a DateTime value returned from my server. The DateTime value is in UTC. I am binding to that data in the XAML in my Silverlight app. How do I convert that UTC date to a local date in my XAML?

Answers & Comments...

Answer: 1

To do it in XAML, you will need to create a converter class that implements the IValueConverter interface: http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx

Then, in your XAML, apply the converter when doing the binding.

<TextBlock Text="{Binding Path=Date, Converter={StaticResource DateFormatter}}"/>  
by : Gambithttp://stackoverflow.com/users/289266




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog