Reduce the bottom and top space in Listview in Xaml(UWP-Universal windows platform)

流过昼夜 提交于 2019-12-02 12:57:36

ListViewItem has a MinWidth and MinHeight by default. By checking ListViewItem styles and templates, we can find the MinWidth and MinHeight properties are specified as following.

<Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}"/>
<Setter Property="MinHeight" Value="{ThemeResource ListViewItemMinHeight}"/>

<x:Double x:Key="ListViewItemMinWidth">88</x:Double>
<x:Double x:Key="ListViewItemMinHeight">44</x:Double>

To reduce the gap, you can set the MinHeight to the value you want like:

<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Margin" Value="0,0,0,0" />
        <Setter Property="Padding" Value="0,0,0,-6" />
        <Setter Property="MinHeight" Value="20" />
        ...
    </Style>
</ListView.ItemContainerStyle>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!