我正在ItemsControl中显示一个List<string>
集合。问题是列表项之间没有间隔,比如TheyAreAllNextToEachOther
。
我该如何在列表项之间创建一些间距?
<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>
ItemContainerStyle
是 'item container' 的Style
,或者如果你使用的是ListBox
,那么它就是ListBoxItem
的Style
。ItemTemplate
是一个DataTemplate
,它定义了项目的内容应该看起来像什么。因此,在ItemContainerStyle
中,你可以访问容器的属性(例如ListBoxItem.IsSelected
),而在DataTemplate
中,你可以访问数据项的公共类属性。 - Sheridan