Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set WPF ListView row height?

I've got a listView displaying a few text records. I need to increase the height of rows (working on a touch screen so I need thicker rows) without increasing the font size.

This is probably pretty trivial but I have no clue and can't find much on google.

Any help appreciated.

like image 577
JohnIdol Avatar asked Aug 07 '09 10:08

JohnIdol


2 Answers

You can set the height of all ListViewItems in a ListView by using ItemContainerStyle:

<ListView>     <ListView.ItemContainerStyle>         <Style TargetType="ListViewItem">             <Setter Property="Height" Value="50" />         </Style>     </ListView.ItemContainerStyle> </ListView> 
like image 73
Andy Avatar answered Sep 23 '22 18:09

Andy


Or you could use styles to set it for all listviews. Here scoped to within a window:

<Window x:Class="WpfApplication2.Window1"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="Window1" Height="300" Width="300">      <Window.Resources>         <Style TargetType="ListViewItem">             <Setter Property="Height" Value="100"/>         </Style>     </Window.Resources>     ... </Window> 
like image 25
Thomas Sandberg Avatar answered Sep 22 '22 18:09

Thomas Sandberg