ListView中的Xamarin.Forms Vertical StackLayout仅显示一个(第一个)Child

Sre*_*raj 3 xaml xamarin xamarin.forms

<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>
Run Code Online (Sandbox Code Playgroud)

我在Xamarin.Forms应用程序中呈现自定义ListView.在StackLayout其中包含两个LabelS(到"消息"和"发件人"已绑定),目前只显示一个孩子.使用上面的代码,它只显示"消息".如果我改变代码

<StackLayout
      BackgroundColor="Gray"
      Orientation="Vertical"
      VerticalOptions="Center">
      <Label
         Text="{Binding Sender}"
         XAlign="Start"
         TextColor="Red"/>
      <Label
          Text="{Binding Message}"
          XAlign="Start"/>
  </StackLayout>
Run Code Online (Sandbox Code Playgroud)

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

Sre*_*raj 8

问题类似于@Grisha所指出的.RowHeight被证明是较小的,第二个StackLayout被削减了.

解决的办法是设置HasUnevenRows的属性ListViewTRUE.因此,RowHeight自动计算.