简体   繁体   中英

How can I localize strings in WP7?

I followed the tutorial on msdn about localization, and they implement localized bindings like this:

{Binding Path=Localizedresources.AppName, 
         Source={StaticResource LocalizedStrings}}

But when I work with Expression Blend localized bindings are implemented like this:

{Binding Localizedresources.AppName, Mode=OneWay}

I don't understand why they are different. Is there a reason why MSDN and Expression Blend do it differently? Is there a reason why I should prefer one way over another?

The former is the implementation for Windows Phone, as Windows Phone don't support static class bindings (as opposed to WPF).

The latter is for WPF, and shouldn't work in Windows Phone.

Also, if you want Expression Blend support for your localization, add the LocalizedStrings resource to the DesignTimeResources.xaml file (typically located in the Properties folder). Then once you build your project, Expression Blend will show the localization at design-time as well.

此外,如果您希望能够在运行时更改语言,一个简单而有用的技巧是在更改线程上的当前(UI)文化后 - 在“AppName”上调用PropertyChanged - 它将立即更新所有本地化字符串你的应用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM