在XAML中的ListView内拉伸网格

时间:2012-09-28 10:06:23

标签: wpf xaml winrt-xaml

Grid内有ListView。如果我将Grid 放在ListView之外,它会正确拉伸以填充屏幕。如果我将放在 ListView内,则不会。这是我的代码

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <ListView HorizontalContentAlignment="Stretch">
        <ListViewItem>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0">Title</TextBlock>
                <TextBlock Grid.Column="0" Grid.Row="1">Text</TextBlock>
                <Button Grid.Column="1">Pin</Button>
            </Grid>
        </ListViewItem>            
    </ListView>
</Grid>

如何让Grid拉伸并填充ListView

1 个答案:

答案 0 :(得分:10)

您可能需要将HorizontalContentAlignment的{​​{1}}设置为ListViewItem