0

I am having a problem in fixing 3 TextBlocks inside a Grid,in a metro App,I used this link enter link description here

but I get always a problem in stretching my TextBlocks inside the Grid this is my code:

<ListView  Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
                        <ListView.ItemTemplate >
                            <DataTemplate>
                        <Grid  Margin="0" HorizontalAlignment="Stretch">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Border Margin="0">
                                <Image Grid.Column="0" Source="images/img1.png"  Margin="0,5"  Stretch="Fill" Width="80"/>
                            </Border>
                            <Grid Grid.Column="1"  Margin="5" HorizontalAlignment="Stretch" >
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <TextBlock  x:Name="text1" Text="test1"  Grid.Row="0" Margin="5" HorizontalAlignment="Stretch" ></TextBlock>
                                <TextBlock  x:Name="text2" Text="test2" Grid.Row="1" HorizontalAlignment="Stretch" ></TextBlock>
                                <TextBlock x:Name="text3" Text="test3" Grid.Row="2" HorizontalAlignment="Stretch" ></TextBlock>
                            </Grid>
                        </Grid>
                        </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

so please I need your help,to fix that thanks for help

Community
  • 1
  • 1
hanali
  • 227
  • 7
  • 17

1 Answers1

1

You have to edit style of ListViewItem and set HorizontalAlignment to Stretch

<ListView>
   <ListView.ItemContainerStyle>
      <Style TargetType="ListViewItem">
          <Setter Property="HorizontalAlignment"
                  Value="Stretch" />
          <Setter Property="HorizontalContentAlignment"
                  Value="Stretch" />
      </Style>
   </ListView.ItemContainerStyle>
</ListView>
Tomasz Pikć
  • 753
  • 5
  • 21