如何设置WPF ListView行高?

Joh*_*dol 27 wpf layout listview row-height

我有一个listView显示一些文本记录.我需要增加行的高度(在触摸屏上工作,所以我需要更粗的行)而不增加字体大小.

这可能是微不足道的,但我没有线索,在谷歌上找不到太多.

任何帮助赞赏.

And*_*ndy 67

您可以设置所有的高度ListViewItemsListView使用ItemContainerStyle:

<ListView>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="Height" Value="50" />
        </Style>
    </ListView.ItemContainerStyle>
</ListView>
Run Code Online (Sandbox Code Playgroud)


Tho*_*erg 8

或者您可以使用样式为所有列表视图设置它.这里限定在一个窗口内:

<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>
Run Code Online (Sandbox Code Playgroud)