在列表框中添加行之间的间距

时间:2016-01-13 11:52:10

标签: c# wpf listbox

我有一个Listbox,它有一个ItemSource绑定到后面代码中的属性。

<Border BorderBrush="#d6786a" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="2" Grid.Column="15" Grid.Row="5" Grid.ColumnSpan="3">
    <ListBox x:Name="ListSrc" Background="#ececec" ItemsSource="{Binding Path=ListBoxData}" dd:DragDrop.IsDragSource="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="Transparent" BorderThickness="0">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="4" Margin="15"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
        </ListBox.Resources>
    </ListBox>
</Border>

从下图中可以看出,这些项目正好在彼此之上/之下。我怎么能在行之间添加一些填充?

enter image description here

1 个答案:

答案 0 :(得分:5)

将这样的内容添加到AsyncTask

ListBox