How do I...Override the default language (US English)
3 posts
• Page 1 of 1
How do I...Override the default language (US English)
When you use data binding and the target property is a string, WPF formats the value using US English irrespective of the user-defined language preference on Microsoft Windows. To force WPF to use the user-defined language preference, add the following code before loading any GUI (the Application.Startup event is a good place):
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(
CultureInfo.CurrentCulture.IetfLanguageTag)));
-
Fiona|Dyalog - Posts: 74
- Joined: Mon Apr 22, 2013 12:59 pm
Re: How do I...Override the default language (US English)
Hello Fiona, your code is written in C#. What would be the equivalent in Dyalog Apl ?
Thanks.
Thanks.
-
PGilbert - Posts: 440
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: How do I...Override the default language (US English)
My apologies – there is an APL function to do this for you in #.WPF.Xaml (courtesey of Michael Hughes):
Used as #.WPF.Xaml.FixLocale '' (as soon as you start).
FixLocale ra;⎕USING;fpm;CultureInfo
⍝ Fixes the locale for Xaml StringFormat etc.
⍝ MUST be used before any Show - fixes a bug in WPF which assumes US locale settings
⍝ ra ←→ Locale indicator, currently only '' supported - choose system locale
⍝
⎕USING←'' 'System.Windows,WPF/PresentationFramework.dll'
⎕USING,←'System.Globalization' 'System.Windows,WPF/PresentationCore.dll' 'System.Windows.Markup'
fpm←⎕NEW FrameworkPropertyMetadata(XmlLanguage.GetLanguage(⊂CultureInfo.CurrentCulture.IetfLanguageTag))
:Trap 90
FrameworkElement.LanguageProperty.OverrideMetadata FrameworkElement fpm
:EndTrap
⍝ c mjh 30Apr2013
Used as #.WPF.Xaml.FixLocale '' (as soon as you start).
-
Fiona|Dyalog - Posts: 74
- Joined: Mon Apr 22, 2013 12:59 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group