【发布时间】:2010-11-09 00:43:07
【问题描述】:
我正在尝试将字典中的 KeyValuePair 元素绑定到 ItemsControl。 我的字典有 15 个元素,下面的代码显示了 15 个文本框:
<WrapPanel Name="PersonsWrapPanel" Grid.Row="0">
<ItemsControl ItemsSource="{Binding Persons}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Width="auto">
</WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Value.Text}"></TextBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>
很遗憾没有任何文本框内容(可能是键或值)。 有什么想法吗?
【问题讨论】:
标签: c# wpf dictionary itemscontrol