我有一个列表框,我想遍历我的Foo对象中的一组酒吧。如何正确绑定WPF中的ListBoxItem?
<ListBox DataContext="{Binding Path=Foo.Bars}" >
<ListBox.Items>
<ListBoxItem>
<ContentControl DataContext="{Binding Path=.}" />
</ListBoxItem>
</ListBox.Items>
</ListBox>
这是我想要使用的数据素材。
<DataTemplate DataType="{x:Type Bar}">
<Label Content="hello stackoverflow" />
</DataTemplate>
如果我探听( - >使用工具史努比检查)我的申请,我注意到整个集合酒吧绑定到ContentControl中,在短短1代替。
我该如何正确绑定,以便对集合的迭代进行得很好?
我实现了这一点,它不起作用。 – Natrium 2009-02-03 10:28:52
我建议你在你的问题中输入你的目标代码。在我的答案中有一些语法错误,我纠正它(资源,不Resouce,忘记GridView,我用手输入所有内容...)。 – belaz 2009-02-03 10:41:34