I want to set height of the ListView
in XAML file for iOS Device using below mentioned code and bindings.
<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>
I've tried to set Row Height of List View statically as well but that also doesn't work.
I haven't given any height and set Grid RowDefinition height = "*" but then also it doesn't set the height of the ListView instead it overlaps the details on the next ListView row.
Thanks.
Try using a StackLayout instead of a ListView:
<StackLayout BindableLayout.ItemsSource="{Binding Items}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Margin="0,0,0,5">
<Label Text="{Binding Name}"/>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
On iOS
, when you set ListView.HasUnevenRows
to true
, you also have to set the Cell.Height
for each cell property too, as the renderer can not infer it from the content.
You can also use ListView.RowHeight
like you do in your example, for even rows. In that case, do not set ListView.HasUnevenRows
(or set it to false
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With