Localization of WPF bindings

  • Thread starter Thread starter Kirill
  • Start date Start date
K

Kirill

Hello,

There is a good chance that there is a better group to post this question,
but unfortunately I failed to find one. Any points in the right direction
will be greatly appreciated.

The question concerns localization of date, time and number formats in WPF
windows.
Here is what I want:
a WPF window with a text field, bound to a DateTime DependencyProperty,
formatted according to easily configurable property.

Here is what I found:
- such field is NOT formatted according to CultureInfo.CurrentCulture (which
is set at the very beginning of the application, even before any windows are
created, with Thread.Culture.CurrentCulture = ...);

- such field is NOT formatted according to CultureInfo.CurrentUICulture (set
in a similar way);

- such field is formatted according to the Language property of the window.
However, the Language property needs to be set on each window individually,
which causes a lot of headaches in my code (there are quite few windows
already).

The question:
Is there any way to force the formatting of date-, time- and numbers-bound
text fields in WPF?

Thank you for any help and ideas!

Kirill.
 
Hello,

Welcome to Microsoft Newsgroup Support Service! My name is Marco Zhou. It's
my pleasure to work with you on this thread.

In WPF, the Language property of FrameworkElement will default to US
English, in order to override it with the current language setting, you
could try overriding the FrameworkElement.Language property's property
metadata as demonstrated in the following blog post:

http://serialseb.blogspot.com/2007/04/wpf-tips-1-have-all-your-dates-times.h
tml

If you have any further questions on this issue, free feel to ask here, we
are glad to answer them.

--------------------------------------------------
Best regards,
Macro Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top