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)
它只显示发件人.简而言之,它只显示第一个孩子.我在这做错了什么?
问题类似于@Grisha所指出的.RowHeight被证明是较小的,第二个StackLayout被削减了.
解决的办法是设置HasUnevenRows的属性ListView是TRUE.因此,RowHeight自动计算.
| 归档时间: |
|
| 查看次数: |
4324 次 |
| 最近记录: |