Wpf Listview Stretch

时间:2014-01-04 16:49:14

标签: c# wpf listview store stretch

我想从代码中看到3对textblock,listview以适应我的屏幕高度。 问题是,当新的listviewitems进入scrollviewer而不是保持相同并添加Vertical scroll时,它会增长并超出我给它的1/3。

<Grid Grid.Column="0">
     <Grid.RowDefinitions>
         <RowDefinition Height="1*" />
         <RowDefinition Height="1*" />
         <RowDefinition Height="1*" />
     </Grid.RowDefinitions>

     <Grid Grid.Row="0">
        <Grid.RowDefinitions>
           <RowDefinition Height="Auto"/>
           <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock TextWrapping="Wrap" Text="" Style="{StaticResource BodyTextBlockStyle}" Grid.Row="0"/>
        <ScrollViewer Grid.Row="1" VerticalScrollMode="Auto" Background="#FF696969" Margin="0,5,0,0">
        <ListView x:Name="" VerticalAlignment="Stretch" Tapped="" >
            <ListView.ItemContainerStyle>
               <Style TargetType="ListViewItem">
                 <Setter Property="Padding" Value="5"/>
                 <Setter Property="Margin" Value="0,0,17,0"/>
               </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        </ScrollViewer>
      </Grid>
...

P.S 对于那些在使用ListView“吃”第一个字符时遇到问题的人,您可以使用:

<ListView.ItemContainerStyle>
      <Style TargetType="ListViewItem">
         <Setter Property="Padding" Value="5"/>
         <Setter Property="Margin" Value="0,0,17,0"/>
      </Style>
</ListView.ItemContainerStyle>

0 个答案:

没有答案