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

后端 未结 1 1499
青春惊慌失措
青春惊慌失措 2021-01-27 21:27

I am working on the universal windows platform app for windows- 10.I have issue regarding the listview.When i click and hover on the listview item the selected area background i

相关标签:
1条回答
  • 2021-01-27 21: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>
    
    0 讨论(0)
提交回复
热议问题