Windows phone 7 如何访问XAML中的字符串资源?

Windows phone 7 如何访问XAML中的字符串资源?,windows-phone-7,Windows Phone 7,我已经在我的主应用程序文件夹中定义了AppResource.resx。在它中,我定义了保存字符串的字符串名OVERVIEW 然后我将其添加到我的App.xaml中,如下所示: <!--Application Resources--> <Application.Resources> <local:LocalizedStrings xmlns:local="clr-namespace:AwesomeApp.WP" x:Key="Local

我已经在我的主应用程序文件夹中定义了
AppResource.resx
。在它中,我定义了保存字符串的字符串名
OVERVIEW

然后我将其添加到我的App.xaml中,如下所示:

    <!--Application Resources-->
    <Application.Resources>
        <local:LocalizedStrings xmlns:local="clr-namespace:AwesomeApp.WP" x:Key="LocalizedStrings"/>
    </Application.Resources>

你走错了路。将XAML中的“LocalizedResources.OVERVIEW”更改为“AppResources.OVERVIEW”,或将AppResources属性重命名为.CS中的LocalizedResources

顺便说一句,我很失望Blend中不支持这一点,我通常将本地化字符串作为视图模型的只读属性公开,并使用数据绑定来访问它们。对我来说,它比长的“{Binding Path=LocalizedResources.OVERVIEW,Source={StaticResource LocalizedStrings}}”表达式工作得更好

<TextBlock Text="{Binding Path=LocalizedResources.OVERVIEW, Source={StaticResource LocalizedStrings}}" />
    public class LocalizedStrings
    {
        public LocalizedStrings()
        {
        }

        private static AppResources localizedResources = new AppResources();

        public AppResources AppResources
        {
            get { return localizedResources; }
        }
    }