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开发者_如何学Python 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.
Try inserting this code in the constructor of the UserControl which is using the DatePicker
before the call to InitializeComponent
.
Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
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.
精彩评论