如何将resx资源分配给itemtemplate控件

时间:2013-05-21 15:49:12

标签: xaml localization windows-phone datatemplate

在我的WP8应用程序中,我有单选按钮,可通过datatemplate对其进行自定义,并在其中嵌入文本块。我的问题是如何从我的resx资源文件中分配一个键来分配文本值,这样我就可以本地化这些datatemplate控件名称而没有任何问题。

以下是我的示例xaml:

<TextBlock x:Name="lblTileColor" TextWrapping="Wrap" Text="{Binding LocalizedResources.Themes_Tile_label, Source={StaticResource LocalizedStrings}}" />

<RadioButton x:Name="accentColor" GroupName="tileColor" IsChecked="true">
                    <RadioButton.ContentTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Rectangle Width="25" Height="25" Fill="{StaticResource PhoneAccentBrush}"/>
                                <TextBlock Width="10"/>
                                <TextBlock x:Name="lblDefaultAccent" Text="{Binding LocalizedResources.Themes_Tile_Default, Source={StaticResource LocalizedStrings}}" />
                            </StackPanel>
                        </DataTemplate>
                    </RadioButton.ContentTemplate>
                </RadioButton>

这里我试图将Themes_Tile_Default resx密钥分配给名为lblDefaultAccent控件的文本块。 使用上面的代码我看到Datatemplate部分中的xaml错误(即无效的XA​​ML) - 如果我直接用硬编码分配文本值它正在工作......

解决此问题的任何帮助?

0 个答案:

没有答案
相关问题