1

I've just learnt to my surprise that WPF doesn't use the CurrentCulture for bindings, instead defaulting to en-US.

In a pure WPF application, this can be fixed in one place by setting the language globally once in the App class.

However I have a WinForms application that is being progressively migrated to WPF, and contains several WPF UserControls. What's the best/simplest way to ensure the CurrentCulture is used for all UserControls? Do I really have to make all my UserControls inherit from a base class that does this, or is there some way to set it globally?

Community
  • 1
  • 1
Joe
  • 122,218
  • 32
  • 205
  • 338

2 Answers2

1

You can use a slightly different approach and derive once from ElementHost and manipulate your WPF UserControl instances as they are instantiated. For example, you can create a LocalizingElementHost with a ChildChanged event handler that does to the child what you would have done in a base class.

Rick Sladkey
  • 33,988
  • 6
  • 71
  • 95
  • Changed my accepted answer to this one. Deriving from ElementHost is looking more and more attractive - the latest good reason being to implement the workaround in this KB article: http://support.microsoft.com/kb/955753 – Joe May 04 '11 at 19:27
1

You can still use the same approach with LanguageProperty.OverrideMetadata, just put it at the beginning of your program (Main method).

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
  • +1 - both this and Rick Sladkey's answers are equally valid, I'm accepting this one as it's what I ended up implementing. – Joe Apr 29 '11 at 13:11