如何在WP7中的c#代码中获取资源String?

ewg*_*egw 4 c# windows-phone-7

我按照本教程本地化我的应用程序:http: //msdn.microsoft.com/en-us/library/ff637520%28v=vs.92%29.aspx#Y1210

所以我创建了这个类:

namespace Foo
{
    public class LocalizedStrings
    {
        public LocalizedStrings()
        {
        }

        private static Foo.AppResources localizedresources = new Foo.AppResources();

        public Foo.AppResources Localizedresources { get { return localizedresources; } }

    }
}
Run Code Online (Sandbox Code Playgroud)

当我{Binding Path=Localizedresources.String1, Source={StaticResource LocalizedStrings}}在XAML文件中使用它时效果很好,但是

如何在源代码中访问String1,例如设置atextBlock.Text

Mat*_*cey 15

在C#中你可以这样做:

textBlock.Text = AppResources.MyLocalizedString;
Run Code Online (Sandbox Code Playgroud)

或者在XAML中:

<TextBlock Text="{Binding Path=LocalizedResources.MyLocalizedString, Source={StaticResource LocalizedStrings}}" >
Run Code Online (Sandbox Code Playgroud)