我正在使用WPFLocalizationExtension我的 WPF 应用程序。我有一个ComboBox用于语言选择。项目来源ObservableCollection<KeyValuePair<string, string>>如下:
TITLE_LANGUAGE_ENGLISH:enTITLE_LANGUAGE_VIETNAMESE:vi-VN
这是我的 xaml 代码:
<TextBlock Text="{lex:Loc TITLE_LANGUAGE}"></TextBlock>
<ComboBox Grid.Column="1"
ItemsSource="{Binding AvailableLanguages}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{lex:Loc Key={Binding Key}}"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
当我运行应用程序时,它会抛出如下异常:
不能在“LocExtension”类型的“键”属性上设置“绑定”。只能在 DependencyObject 的 DependencyProperty 上设置“绑定”
我该如何翻译ItemTemplate?
谢谢,