[英]How to add the spacing between the items in ListBox Wpf
我有一個包含ListBoxItems的ListBox,我已經將Button作為ListBoxItems以Vertical形式添加。 按鈕之間的空格由邊距設置。 但是,當我單擊按鈕下方時,它正在調用該事件。
我該如何刪除? 以及如何將ListBoxItem和Margin的高度設置為該項目?
您可以使用ListBox.ItemContainerStyle
作為獲取或設置呈現項目容器時使用的樣式( 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.