在通用应用程序的网格内拉伸 TextBlocks

stretch TextBlocks inside a Grid in a universal App

我在修复网格内的 3 个 TextBlock 时遇到问题,在地铁应用程序中,我使用了这个 link enter link description here

但我在网格内拉伸我的 TextBlocks 时总是遇到问题 这是我的代码:

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

所以我需要你的帮助来解决这个问题 感谢帮助

您必须编辑 ListViewItem 的样式并将 Horizo​​ntalAlignment 设置为 Stretch

<ListView>
   <ListView.ItemContainerStyle>
      <Style TargetType="ListViewItem">
          <Setter Property="HorizontalAlignment"
                  Value="Stretch" />
          <Setter Property="HorizontalContentAlignment"
                  Value="Stretch" />
      </Style>
   </ListView.ItemContainerStyle>
</ListView>