How do you change the height of items in a ListView control in a Windows 10 UWP app?
For example in UWP, the following does not make the row height 20. (WPF questions might suggest this, but it does not seem to work in the UWP XAML):
<ListView x:Name="listView" IsItemClickEnabled="True">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Height" Value="20" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Height="20">
<TextBlock Text="{Binding Title}" TextWrapping="NoWrap" Foreground="White" Height="20"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
You need to also set the MinHeight
property:
<Style TargetType="ListViewItem">
<Setter Property="Height" Value="20" />
<Setter Property="MinHeight" Value="20" />
</Style>
You can also override the style of your data template.
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<x:Double x:Key="ListViewItemMinHeight">20</x:Double>
<x:Double x:Key="ListViewItemHeight">20</x:Double>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Page.Resources>
http://loekvandenouweland.com/content/UWP-lightweight-listview-styling.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With