1

I am trying to figure out how to get rid of the padding below the text in a listview row:Listview Row

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.

1 Answers1

3

Try adding

 <ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="MinHeight" Value="0"/>
    </Style>
</ListView.ItemContainerStyle>

to your List View or use Live Property Explorer and Live Visual Tree Viewer from Visual Studio and peek into the ListViewItem.

Alex Witkowski
  • 545
  • 1
  • 6
  • 13
  • 3
    Thanks, I wasn't aware of the Live Property Explorer and Live Visual Tree Viewer tools or how to modify the container style. Learn something new each day! Your snippet works fine except the property that needed modifying is the Height property so: `` works just fine. –  Nov 19 '16 at 22:41