开发者

Silverlight (RIA Services) spontaneous culture changing

My RIA enabled Silverlight Application is setting the thread culture in the App constructor (this is absolutley okay since it is an intranet application and will never ever be used by someone who is not german):

public App() {
    InitializeComponent();
    Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
}

It does what it should, the DataForms are displaying datetime values in german notation. BU开发者_运维技巧T: it is spontaneously changing to en-US notation when navigating between items in the data source that is bound to the DataForm. Why?


It seems that the thread culture is not inherited by every control. Just for fun I displayed the Language of the control, and it was alwas set to en-US. To solve this, I hard coded the language de-DE in the style for the DataForm.

The same problem was described by Hannes (in german). Surprisingly in this case it was exactly the other way round: the DataForm was german, but the grid was english.


As Marc Wittke said, the thread culture is not inherited by every control (why on earth???)

Any way, you do not need to hardcode the values, this put this line in your Control constructor:

Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name);

And you control will use the CurrentCulture.

Cheers,

André

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜