【发布时间】:2012-11-15 21:17:14
【问题描述】:
我有一个列表框,我正在尝试使用“metro”应用程序进行数据绑定。这是我的 xaml:
<ListBox x:Name="ImagesList" Margin="40" Grid.Row="1">
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Key}" />
</StackPanel>
</DataTemplate>
</ListBox>
我已经创建了一个来源:
List<KeyValuePair<string, string>> items =
new List<KeyValuePair<string, string>>();
items.Add(new KeyValuePair<string, string>("a", "a"));
items.Add(new KeyValuePair<string, string>("b", "b"));
items.Add(new KeyValuePair<string, string>("c", "c"));
this.ImagesList.ItemsSource = items;
我希望这会在我的应用程序 a、b 和 c 中创建一个文本列表
但是,我为我绑定的每个元素获取了以下文本:
System.Runtime.InteropServices.CLRKeyBaluePairOmpl'2[System.String, System.String]
看起来它正在显示我正在绑定的类型的全名......我做错了什么?
【问题讨论】:
标签: data-binding windows-8 listbox