WPF WrapPanel / StackPanel与DataTemplate? [英] WPF WrapPanel/StackPanel with DataTemplate?
本文介绍了WPF WrapPanel / StackPanel与DataTemplate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在WrapPanel或StackPanel中使用DataTemplate应该怎么做?
What must I do to use a DataTemplate in a WrapPanel or StackPanel?
在ListBox上是如此简单,但我找不到在Panel上做到这一点的方法...
On a ListBox its so easy but i cant find a way to do it on a Panel...
编辑:我想要的是一个类似WrapPanel的放置项的列表框。
What i want is a ListBox that places the items like a WrapPanel.
推荐答案
如果我对您的理解正确,则可以使用容器的ItemsPanel属性。我使用类似的方法使用水平StackPanel制作ItemsControl布局:
If I understand you correctly, you can use the ItemsPanel property of your container. I used something similar to make my ItemsControl layout using a horizontal StackPanel:
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
因此,更具体地针对您的情况:
So, more specifically for your case:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
这篇关于WPF WrapPanel / StackPanel与DataTemplate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文