gurehbgui
gurehbgui

Reputation: 14674

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?

Upvotes: 0

Views: 296

Answers (2)

Filip Skakun
Filip Skakun

Reputation: 31724

Also, if you want to be able to change the language at run-time a simple yet useful trick is to after changing the Current(UI)Culture on your thread - invoke PropertyChanged on "AppName" - it will immediately update all localized strings in your app.

Upvotes: 0

Claus Jørgensen
Claus Jørgensen

Reputation: 26347

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.

Upvotes: 2

Related Questions