我跟着這個教程本地化我的應用程序: 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