[英]How to set ListView Row Height in Xamarin.Forms
我想使用下面提到的代码和绑定为 iOS 设备设置 XAML 文件中ListView
高度。
<ListView Grid.Row="2" Grid.Column="1" ItemsSource="{Binding QuestionAnswerList,Mode=TwoWay}" SelectedItem="{Binding SelectedData,Mode=TwoWay}"
HasUnevenRows="true"
RowHeight="{Binding Custom_height,Mode=TwoWay}"
BackgroundColor="Silver"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
我也尝试静态设置列表视图的行高,但这也不起作用。
我没有给出任何高度并设置 Grid RowDefinition height = "*" 但它也没有设置 ListView 的高度,而是与下一个 ListView 行的细节重叠。
谢谢。
在iOS
,当您将ListView.HasUnevenRows
设置为true
,您还必须为每个单元格属性设置Cell.Height
,因为渲染器无法从内容中推断出它。
您也可以像在示例中一样使用ListView.RowHeight
,即使是行。 在这种情况下,不要设置ListView.HasUnevenRows
(或将其设置为false
)。
尝试使用 StackLayout 而不是 ListView:
<StackLayout BindableLayout.ItemsSource="{Binding Items}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Margin="0,0,0,5">
<Label Text="{Binding Name}"/>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.