Reputation: 657
I'm trying to create a ListView with Xamarin Forms. The RowHeight for each of the list element may very dynamically when it is populated.
Please let me know how we can set the RowHeight of the list item dynamically.
var StatusList = new ListView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
RowHeight = Constants.CategoryRowHeight + 60,
BackgroundColor = Constants.BackgroundColor,
ItemTemplate = GetDataTemplate()
};
Upvotes: 0
Views: 1691
Reputation: 2834
There is a bug on iOS which causes that the rows cannot have different heights. Setting HasUnevenRows=true
only causes that you can set a custom height for ALL cells. If this bug ever gets fixes, I can inform you. But: this will work for UWP and Android, so you can use a different CellView for iOS instead
Upvotes: 1
Reputation: 1225
You can set the HasUnevenRows property of ListView to True.
var StatusList = new ListView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
HasUnevenRows = true,
RowHeight = Constants.CategoryRowHeight + 60,
BackgroundColor = Constants.BackgroundColor,
ItemTemplate = GetDataTemplate()
};
Upvotes: 1