【问题标题】:Culture is set to US in spite of PC region is set to UK尽管 PC 区域设置为英国,但文化设置为美国
【发布时间】:2011-06-13 13:04:05
【问题描述】:

我的电脑区域设置为英国,但我的 silverlight 的默认文化设置为美国。

我发现这篇优秀的帖子解释了这将是 WPF 中的默认行为,他还为此提供了解决方案。

How to set and change the culture in WPF

不幸的是,通常情况下,我无法在 Silverlight 中使用此代码。没有 OverrideMetadata 方法。所以我的问题是 Silverlight 开发人员如何解决这个问题?

非常感谢,

【问题讨论】:

  • 对 Silverlight 开发一无所知,所以我想在查看有关 WPF 本地化的其他信息时将其传递:Localizing Silverlight-based Applications
  • 所有 Windows 应用程序都会出现这种情况:因为 Windows 未本地化为 en-GB。因此,当前文化设置为 en-GB(日期、时间、货币……),但资源的 UI 文化设置为 en-US。

标签: c# .net silverlight silverlight-4.0


【解决方案1】:

经过数周的研究,我终于找到了解决方案。

您在 Silverlight 中所要做的就是将其放入最顶部的窗口(容器或 Prism 中的 Shell)

this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);

归功于此博客:http://timheuer.com/blog/archive/2010/08/11/stringformat-and-currentculture-in-silverlight.aspx

【讨论】:

    【解决方案2】:

    我相信必须在InitializeComponent(); 调用之后直接在构造函数中设置页面的语言,创建一个PageBase 类来做到这一点可能是个好主意,但我很难让设计师喜欢我的过去的页面基类

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多