Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stretch a Grid inside a ListView in XAML

I have a Grid inside a ListView. If I place the Grid outside of the ListView, it correctly stretches to fill the screen. If I place it within the ListView, it does not. Here's my code

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

How do I get the Grid it to stretch and fill the ListView?

like image 226
roryok Avatar asked Sep 28 '12 10:09

roryok


1 Answers

You probaby need to set the HorizontalContentAlignment of the ListViewItem to Stretch.

like image 154
H.B. Avatar answered Oct 13 '22 11:10

H.B.