CurrentUICulture ignores Region and Language settings

前端 未结 2 963
陌清茗
陌清茗 2021-01-12 16:55

Assorted settings in the Windows 7 Region and Language dialog supply values to the properties of the CurrentCulture object. However, WPF controls seem to use CurrentUICultur

2条回答
  •  北海茫月
    2021-01-12 17:45

    This SO post (WPF/Silverlight) has a link to this article (WPF only), explaining how to use CurrentCulture as the default for your application. Does that solve your problem?

    EDIT:

    Making bindings use the custom settings from "Region and Language" instead of the current language's default settings requires some more trickery. This post concludes that every binding's ConverterCulture also has to be explicitly set to CultureInfo.CurrentCulture. Here are some DateTime tests:

    
    
    
        
        
    
        
        
    
        
        
    
        
        
    
    
    

    The custom binding class:

    public class CultureAwareBinding : Binding
    {
        public CultureAwareBinding()
        {
            this.ConverterCulture = System.Globalization.CultureInfo.CurrentCulture;
        }
    }
    

    It all ends up looking like this on a norwegian machine:

    WPF DateTime Bindings

提交回复
热议问题