WPF ItemsControl中的项目间距 [英] Item spacing in WPF ItemsControl
本文介绍了WPF ItemsControl中的项目间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ItemsControl中显示 List< string>
集合。问题是列表项之间没有空格,例如它们是AreAreAllNextToEachOther
。
I'm displaying a List<string>
collection in an ItemsControl. The problem is that there is no spacing between the list items such as TheyAreAllNextToEachOther
.
如何创建一些间隔在项目之间?
How can I create some spacing between the items?
<ItemsControl Grid.Column="2"
Grid.ColumnSpan="2"
ItemsSource="{Binding Path=ShowTimes}"
BorderThickness="0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
推荐答案
我将添加一个ItemTemplate来设置边距
I'd add an ItemTemplate where you set the margin
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="3,3,3,3" Text="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
这篇关于WPF ItemsControl中的项目间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文