Domanda

Ho un listView la visualizzazione di alcuni record di testo. Ho bisogno di aumentare l'altezza delle righe (che lavorano su un touch screen quindi ho bisogno di righe più spesse) senza aumentare la dimensione del carattere.

Questo è probabilmente abbastanza banale, ma non ho idea e non riesce a trovare molto su google.

Qualsiasi aiuto apprezzato.

È stato utile?

Soluzione

È possibile impostare l'altezza di tutti ListViewItems in un ListView utilizzando ItemContainerStyle:

<ListView>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="Height" Value="50" />
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

Altri suggerimenti

In alternativa è possibile utilizzare gli stili per impostare per tutti listviews. Qui ambito di all'interno di una finestra:

<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>

Nel 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>

In C # Codebehind

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

Spero che ricevendo l'Idea.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top