使用 MVVM Light 本地化 WP7 应用程序
我在 Windows Phone 7 应用程序中使用 MVVM Light。该应用程序以英语和西班牙语使用。用户可以在运行时选择不同的语言。我正在使用资源文件本地化应用程序。我已经能够进行本地化,但前提是我从“设置”中更改语言。在主页中,我有一个列表供用户在运行时选择语言,我将所选语言设置为 Thread.CurrentThread.CurrentCulture,但界面中的文本字符串没有显示已更新。我在 ViewModel 中有一组属性,我将它们绑定到视图以设置控件的标签,但缺少一些内容。我一直在阅读,我需要在 ViewModel 中实现 INotifyPropertyChanged 才能使其正常工作,但我不知道如何准确地做到这一点,也不知道是否有其他更好的方法来实现这种情况使用 MVVM Light。有人可以帮我吗?
I'm using MVVM Light in my Windows Phone 7 application. The application is to be used in English and Spanish. Users can select a different language during runtime. I'm localizing the application using resource files. I've already been able to make the localization works, but only when I change the language from Settings. In the main page, I have a list for users to select the language during runtime, I'm setting the selected language to Thread.CurrentThread.CurrentCulture, but the text strings in the interface don't get updated. I have a set of properties in the ViewModel that I'm binding to the View to set the labels of the control, but something is missing. I've been reading that I need to implement the INotifyPropertyChanged in the ViewModel to make this works, but I don't know how to exactly do that nor if there is a different better way to implement this case using MVVM Light. Could anybody help me here please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,我有时写过一篇关于它的博客文章( http://wp7wonders.wordpress.com/2010/10/17/localize-a-windows-phone-7-application/ - 也请阅读评论!)。要点是资源文件和视图模型之间有一个对象,它允许动态更改语言。
Hum, I wrote a blog post about it sometimes ago ( http://wp7wonders.wordpress.com/2010/10/17/localize-a-windows-phone-7-application/ - read the comments too!). The main point is that you have an object between the resource files and your viewmodels which allow to change the dynamically the language.