I am trying to use PL in my projects and now I stuck with localization. I moved with my Resources and LocalizedStrings to PL project. My LocalizedStrings look like this:
namespace Activity.Localization
{
public class LocalizedStrings : INotifyPropertyChanged
{
public LocalizedStrings()
{
}
private static Resources.AppResources localizedResources = new Resources.AppResources();
public Resources.AppResources LocalizedResources { get { return localizedResources; } }
public void ResetResources()
{
OnPropertyChanged("LocalizedResources");
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
}
}
and resources are in Resources folder (it's auto-generated from Windows phone project).
Now in my View I have this for button (Windows Phone project, MainPage.xaml):
<controls:MenuButton x:Name="btnStartGame"
Text="{Binding Path=LocalizedResources.btnStartGame, Source={StaticResource localization:LocalizedStrings}}"
Tap="btnStartGame_Click"
Height="80" Width="400"
FontSize="30" Margin="12"/>
It compiles and build but when app start I get exception:
Cannot find a Resource with the Name/Key localization:LocalizedStrings
So I think I must do some changes to get localization to portable libraries but which one? How can I change that to have it working? Thanks
You need to add your StaticResource in the App.xaml:
http://www.geekchamp.com/articles/localizing-a-windows-phone-app-step-by-step