I'm trying to change ViewCell on listview, but the code below not work for me:
<DataTemplate>
<ViewCell Height="100">
<StackLayout Orientation="Horizontal">
<Image Source="{Binding Seller.Thumbnail}}" Aspect="AspectFit" />
<StackLayout Orientation="Vertical" >
<Label Text="{Binding CouponName}" FontAttributes="Bold" FontSize="12" />
<Label Text="{Binding EndOffer}" FontSize="11" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
To change the height of tableView cell in ios dynamically, i.e resizing the cell according to the content available, we’ll need to make use of automatic dimension property. We’ll see this with the help of an sample project. Create an empty project and go to it’s viewController class, conform it to UITableViewDataSource and UITableViewDelegate.
However , you can change your StackLayout's HeightRequest property to achieve what you want. "generally" being the key term here. In the case of ViewCell however it is get/set. If you look at the intellisense that pops up on that property in Visual Studio this is confirmed.
If you want to set ViewCell.Height instead then set ListView.HasUnevenRows to true (but it has some performance impact) Setting the height for the ViewCell will work only if ListView.HasUnevenRows or TableView.HasUnevenRows property set to true. True, but see Daniel Luberda's more complete answer above, which already said this.
So setting the .Height of a CellView can appear to to not have any affect. It is primarily meant to be used in conjunction with ListVIew.HasUnevenRows=true
ListView.RowHeight
property on
ListView itselfViewCell.Height
instead
then set ListView.HasUnevenRows
to true
(but it has some performance impact)The correct now in 2019 is put this for fix height:
<ListView RowHeight="100" />
If yout don't want fix height in all rows, use:
<ListView HasUnevenRows="true" />
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