Culture is set to US in spite of PC region is set to UK
My PC's region is set to United Kingdom, but my silverlight's default culture is set to US.
I have found this excellent post explaining this would be the default behaviour in WPF and he a开发者_Go百科lso provides a solution for it.
How to set and change the culture in WPF
Unfortunately as its usually the case I can't use this code in Silverlight. There is no OverrideMetadata method. So my question is how do the Silverlight developers solve this problem?
Highly appreciated,
I have finally found the solution, after weeks of research.
All you have to do in Silverlight is to put this into the top most window (container or Shell as in Prism)
this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
Credit goes to this blog: http://timheuer.com/blog/archive/2010/08/11/stringformat-and-currentculture-in-silverlight.aspx
I believe one has to set the page's Language in the constructor directly after the InitializeComponent();
call, it could be a good idea to create a PageBase
class to do this but I have had difficulty getting the designer to like my Page base classes in the past
精彩评论