我有一个包含 ListBoxItems 的 ListBox,我已将按钮添加为垂直形式的 ListBoxItems。 按钮之间的空间由边距设置。 但是当我点击按钮下方时,它正在调用该事件。
我应该如何删除它?以及如何将 ListBoxItem 的高度和边距设置为该项目?
最佳答案
您可以使用 ListBox.ItemContainerStyle
for 获取或设置呈现项目容器时使用的样式 (ListBoxItems
),这里 Margin 将为您完成所需的任务:尝试以下代码:
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Margin" Value="5"/>
<Setter Property="Height" Value="75"/> <!-- For setting height of control-->
<Setter Property="Width" Value="75"/> <!-- For setting widthof control-->
</Style>
</ListBox.ItemContainerStyle>
关于c# - 如何在ListBox Wpf中添加项目之间的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36350287/