Peekay
Peekay

Reputation: 451

Inner grid present in listview item is not stretching

In my List view I use a grid to arrange the controls of list view item here is the code

<ListView.ItemTemplate>
                                            <DataTemplate>
                                                <Border>
                                                    <!--<Label Width="Auto" HorizontalAlignment="Stretch"  Height="3"  Background="LightGray"></Label>-->
                                                    <Grid HorizontalAlignment="Stretch" MinWidth="220" >
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="Auto" />
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="65*"/>
                                                            <ColumnDefinition Width="10" />
                                                            <ColumnDefinition Width="25*" />
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontWeight="Bold"  Text="{Binding Path=Name}"/>
                                                        <TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Text="{Binding PlanDate.DateValue,StringFormat=d}"></TextBlock>
                                                        <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Text="{Binding Owner}"></TextBlock>
                                                        <TextBlock Grid.Row="1" Grid.Column="2"  HorizontalAlignment="Right" Text="{Binding ForecastDate.DateValue,StringFormat=d}"></TextBlock>
                                                    </Grid>
                                                    <!--<Label Width="Auto" HorizontalAlignment="Stretch"  Height="3"  Background="LightGray"></Label>-->
                                                </Border>

                                            </DataTemplate>
                                        </ListView.ItemTemplate>

Here the text blocks in grid coloumn 2 horizontal alignment is set to right .. still the texblocks are not been placed at the right . Am i doing some mistake here? Please advise

Upvotes: 1

Views: 613

Answers (1)

Justin XL
Justin XL

Reputation: 39006

Try adding HorizontalContentAlignment="Stretch" to your ListView (the default value is Left and that's why you see it's not stretched).

You can remove HorizontalAlignment="Stretch" MinWidth="220" in your inner Grid.

Upvotes: 4

Related Questions