我跟着这个教程本地化我的应用程序: http://msdn.microsoft.com/en-us/library/ff637520%28v=vs.92%29.aspx#Y1210如何获取WP7中c#代码中的资源字符串?
所以我创建的类:
namespace Foo
{
public class LocalizedStrings
{
public LocalizedStrings()
{
}
private static Foo.AppResources localizedresources = new Foo.AppResources();
public Foo.AppResources Localizedresources { get { return localizedresources; } }
}
}
当我在XAML文件它的伟大工程使用{Binding Path=Localizedresources.String1, Source={StaticResource LocalizedStrings}}
,但
怎么能我访问源代码中的String1,例如设置textBlock.Text
有没有绑定在C#代码的LocalizedResources另一种方式? – Xander 2014-01-22 10:03:14
@Xander你有上面的具体问题吗?或者你只是好奇? – 2014-01-22 12:25:31
我在WP8中分享我的代码,在我的子项目中我无法使用上面那段代码,因为它会返回父项的值。我想从孩子的AppResources.resx文件中获取值。所以如果我使用Binding b = new Binding()来绑定这个值;我能做到吗?我在这里提出了一个问题http://stackoverflow.com/questions/21258300/in-shared-classes-how-to-use-local-resources – Xander 2014-01-22 12:39:08