Xamarin.FormsListView中的垂直StackLayout只显示一个(第一个)Child

Xamarin.Forms Vertical StackLayout in ListView displays only one (first) Child

<ListView 
    ItemsSource="{Binding Messages}"
    Grid.ColumnSpan="2"
    HeightRequest="100">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.View>
                    <StackLayout>
                        <Label
                            Text="{Binding When}"
                            XAlign="Center"/>
                        <StackLayout
                            BackgroundColor="Gray"
                            Orientation="Vertical"
                            VerticalOptions="Center">
                            <Label
                                Text="{Binding Message}"
                                XAlign="Start"/>
                            <Label
                                Text="{Binding Sender}"
                                XAlign="Start"
                                TextColor="Red"/>

                        </StackLayout>
                    </StackLayout>
                 </ViewCell.View>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

我正在 Xamarin.Forms 应用程序中呈现自定义 ListView。 StackLayout包含两个Label(绑定了"Message"和"Sender"),目前只显示一个child。使用上面的代码,它只显示 "Message"。如果我将代码更改为

<StackLayout
      BackgroundColor="Gray"
      Orientation="Vertical"
      VerticalOptions="Center">
      <Label
         Text="{Binding Sender}"
         XAlign="Start"
         TextColor="Red"/>
      <Label
          Text="{Binding Message}"
          XAlign="Start"/>
  </StackLayout>

它只显示发件人。简而言之,它只显示第一个 child。我在这里做错了什么?

问题与@Grisha 指出的类似。 RowHeight 被证明较小,第二个 StackLayout 被剪裁。

解决方案是将 ListViewHasUnevenRows 属性 设置为 TRUE。因此,RowHeight是自动计算出来的。