Reputation: 7063
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.
Upvotes: 14
Views: 23213
Reputation: 81
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>
Upvotes: 8
Reputation: 16222
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
).
Upvotes: 23