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

Ben*_*rke 0 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>
Run Code Online (Sandbox Code Playgroud)

从下图中可以看出,项目直接在彼此上方/下方.我怎么能在行之间添加一些填充?

在此输入图像描述

Fra*_*tyx 5

添加这样的东西到你的 ListBox

<ListBox.ItemContainerStyle>
    <Style TargetType="ListBoxItem">
        <Setter Property="Padding" Value="20" />
    </Style>
</ListBox.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud)