我正在尝试在我的项目中使用 PL,现在我坚持使用本地化。我将我的 Resources 和 LocalizedStrings 移至 PL 项目。我的 LocalizedStrings 看起来像这样:
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));
}
}
}
}
并且资源位于 Resources 文件夹中(它是从 Windows phone 项目自动生成的)。
现在在我的视图中,我有这个按钮(Windows Phone 项目,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"/>
它编译并构建,但是当应用程序启动时出现异常:
Cannot find a Resource with the Name/Key localization:LocalizedStrings
所以我想我必须做一些改变来获得可移植库的本地化,但是哪一个呢?我怎样才能改变它让它工作?谢谢