Search code examples
c#uwpuwp-xaml

How to change the space between items in ListView UWP


I tried to change merge value by using ListView.ItemContainerStyle, space between items is decreased, but line seletion is not effect.

enter image description here

<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="Margin" Value="0,0,0,-25"/>
    </Style>
</ListView.ItemContainerStyle>

★ How to edit the space and custom line selection like below picture?

enter image description here


Solution

  • Use ControlTemplate is solved my issue.

    <Style x:Key="ListViewItemStyle" TargetType="ListViewItem">
            <Setter Property="MinWidth" Value="{StaticResource SplitViewCompactPaneThemeLength}"/>
            <Setter Property="MinHeight" Value="30"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="UseSystemFocusVisuals" Value="False" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListViewItem">
                        <Grid MinHeight="30" Height="30">
                            My ListView item definition
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
    </Style>