「メトロ」アプリでデータバインドしようとしているリストボックスがあります。ここに私の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]
バインドしている型のフルネームが表示されているようです...何が間違っていますか?