32

いくつかのテキスト レコードを表示する listView があります。フォントサイズを大きくせずに、行の高さを増やす必要があります(タッチスクリーンで作業しているため、より太い行が必要です)。

これはおそらくかなり些細なことですが、私には手がかりがなく、グーグルであまり見つけることができません。

どんな助けでも感謝します。

4

3 に答える 3

77

を使用してListViewItems、すべての高さを設定できます。ListViewItemContainerStyle

<ListView>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="Height" Value="50" />
        </Style>
    </ListView.ItemContainerStyle>
</ListView>
于 2009-08-07T11:02:31.917 に答える
9

または、スタイルを使用してすべてのリストビューに設定することもできます。ここでは、ウィンドウ内を対象としています。

<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>
于 2009-08-07T11:12:34.847 に答える
3

XAML

  <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">
        <Grid>
            <StackPanel>
                <ListView x:Name="myListView">
                    <ListViewItem Height="50">Test</ListViewItem>
                    <ListViewItem Height="30">Test</ListViewItem>
                </ListView> 
            </StackPanel>
        </Grid>
    </Window>

C# コードビハインドで

    foreach (ListViewItem lv in myListView.Items)
    {
        lv.Height = 30;
    }

アイデアが得られることを願っています。

于 2009-08-07T11:00:34.900 に答える