Home > Uncategorized, WPF > Date and Time in WPF

Date and Time in WPF

Recently, i was fighting with a date/Time interpretation which makes me a kind of crazy.The scenario was collecting data from a return dataset based on SQL serve table. When looking in that dataset, the date/Time format of dat fields was formatted correctly based on the culture I get set. But as long as the data was rendering by my WPF gridview, Date/Time value gets disply in different manner.

After browsing around I met Mike Danes on a forums which gets similar trouble.

When you convert a date time to string in code the current (correct) culture is used. However WPF doesn’t use the current culture, it takes the culture name from the Language property of the FrameworkElement and then gets the culture by using GetCultureInfoByIetfLanguageTag. This method returns a standard CultureInfo object, not the user customized version. This has been reported as a bug by Mike already.

To overcome this, it was needed to apply a converter to my date/Time column field.

I would never seen that problem if my users did not start to change cutsom settings of standard culture.

Hope it could save you time as well.
Thanks to Mike as well helping me isolate the issue

Categories: Uncategorized, WPF Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: