如何摆脱Listview行中不必要的填充 [英] How do I get rid of unwanted padding in a Listview row
问题描述
我正在尝试弄清如何摆脱列表视图行中文本下方的填充:
I am trying to figure out how to get rid of the padding below the text in a listview row:
还有我对Listview的标记:
And my markup for the Listview:
<ListView
ItemsSource ="{Binding AllowedApplicants}"
Height="250"
Width="219"
VerticalAlignment="Top"
Grid.Row="3"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="20,5"
BorderBrush="Bisque"
BorderThickness="2">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Padding="5,5" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我不知道这种多余的填充物(红色箭头)是从哪里来的.该行的填充和边距的属性默认情况下均为零.我添加了五个,以使文本不受限制.列表视图行似乎具有无法调整的默认高度.
I can't figure out where this extra padding (red arrow) is coming from. The properties for the row's padding and margins defaults to zero all around. I added the five to keep the text off the borders. The list view row seems to have a default Height which cannot be adjusted.
推荐答案
尝试添加
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="MinHeight" Value="0"/>
</Style>
</ListView.ItemContainerStyle>
进入您的列表视图,或使用Visual Studio中的Live Property Explorer和Live Visual Tree Viewer并浏览ListViewItem.
to your List View or use Live Property Explorer and Live Visual Tree Viewer from Visual Studio and peek into the ListViewItem.
这篇关于如何摆脱Listview行中不必要的填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!