Silverlight DatePicker 控件是否支持切换区域性?
我有一个 Silverlight 应用程序,它允许用户在应用程序中切换语言。切换语言时,我们将 Thread.CurrentThread.CurrentUICulture 设置为新的区域性。这对于我们的本地资源文件非常有用,并且没有任何问题。
但是,Silverlight 日期选择器控件不会切换区域性。它似乎只是继承了最初设定的文化。因此,如果我在 App.xaml.cs 构造函数中切换区域性,那么我会看到其他区域性。但是,如果我在应用程序启动并运行后更改文化,则 DatePicker 控件中的文化不会发生变化。
这可以做到吗?如何做到?
编辑:为了清楚地了解下面的答案(来自评论),我必须将 Thread.CurrentThread.CurrentCulture 设置为新的区域性,以使其在 DatePicker 中切换。
I have a Silverlight application which allows the user to switch languages in the application. When the language is switched we set the Thread.CurrentThread.CurrentUICulture to the new culture. This works great for our local resource files and there are no issues there.
However, the Silverlight datepicker control doesn't switch cultures. It only seems to pick up the culture that was originally set. So if I switch the culture in the App.xaml.cs constructor then I see the other culture. But if I change the culture once the app is up and running it doesn't change in the DatePicker control.
Can this be done and how?
EDIT: To be clear on what the answer was below (from the comment), I had to set the Thread.CurrentThread.CurrentCulture to the new culture to get it to switch in the DatePicker.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在调用
InitializeComponent
之前使用DatePicker
的 UserControl 的构造函数中插入此代码。加载 Xaml 后尝试修改语言不会影响控件的行为。因此,如果您想真正实现文化转换的动态,这可能没有帮助。
Try inserting this code in the constructor of the UserControl which is using the
DatePicker
before the call toInitializeComponent
.Attempts to modify the language after the Xaml has been loaded will not affect the behaviour of the control. So this may not help if you want get really dynamic with your culture switching.