Search code examples
c#wpflistviewitemtemplate

WPF ListView ItemTemplate too large space per Label


I have a data bound ListView that uses a rather strange heights for every ListViewItem after I start using an ItemTemplate.

        <ListView ItemsSource="{Binding Path=AllTvShows}">
            <ListView.ItemTemplate>
                <DataTemplate>
                        <Label FontStretch="Normal" VerticalAlignment="Center" Content="{Binding Path=Name}"/>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

This is how it looks like:

enter image description here

Without the ItemTemplate the labels have the normal height (more adjacent). How should I specify the Label so that it would render normal?


Solution

  • Use a TextBlock instead of a Label:

    <ListView ItemsSource="{Binding Path=AllTvShows}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Path=Name}"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>