开发者

How to consider local culture of user when showing date/time?

I have the situation that my Silverlight app thinks I had the US culture, hence the whole date and time formating is not set correctly to UK.

I would like to set it up this way that any user in the worl开发者_开发技巧d that uses my Silverlight app would get to see the local familiar formatting of date and time. How can I determine and set this in Silverlight 4?

Many Thanks,


Silverlight will choose your computer's regional settings to format your date. You can change your regional settings in your control panel. If you installed your OS using US as country it will be used as default.

If your computer's regional setting is set to UK and if you still have problem then try using ToLocaleString method.

If your browser is mistakenly choosing wrong culture then silverlight will also choose same culture. You can also override culture in silverlight code but it is not advised. The best would be to not touch culture in silverlight code and let it pick up culture from machine.


Try this.. (but ofcource change this code sample)

// р. is the CurrencySymbol for Russia.. 
if (CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol == "р.")
{
    // if user have 'р.' as CurrencySymbol it means that he !!!maybe!!! from 'Russia'
    Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜