I have an app with a CollectionView using a DataTemplate.
The DataTemplate contains a Grid with 2 rows. The top row is a narrow header. Within the top bar is another Grid with 2 rows.
On UWP it displays as I would expect. On iOS and Android the cell in the CollectionView expands to at least twice what it would need. The Header is still narrow but the background of the Cell shows beneath the second row (see screenshots below)
The right side uses the same DataTemplate but the 2 row grid used in the headed to display the 2 lines (Hobby. Golfing) is replaced with a Label with a carriage return. A StackView also works.
On UWP both DataTemplates show a very similar layout.
Steps to Reproduce
Run attached project. Using a CollectionView with a DataTemplate like
CollectionView Items should not be larger than the Layout requests
Actual Behavior
CollectionView Items are too large
Basic Information
Version with issue: Xamarin 4.8.0.1687
Last known good version:
Platform Target Frameworks:
iOS:
Android: 10
UWP: 16299 - 18362
NuGet Packages:
Affected Devices:
Environment
VS2019 16.8.2
Screenshots
Android & iOS. DataTemplate on left with 2 row grid in top row of item (showing "Hobby","golfing")
Same CollectionView on right, using a Label in place of a Grid. The Blue in the items is extra space in each CollectionView item. (default background color of a cell)
Description
I have an app with a CollectionView using a DataTemplate. The DataTemplate contains a Grid with 2 rows. The top row is a narrow header. Within the top bar is another Grid with 2 rows. On UWP it displays as I would expect. On iOS and Android the cell in the CollectionView expands to at least twice what it would need. The Header is still narrow but the background of the Cell shows beneath the second row (see screenshots below)
The right side uses the same DataTemplate but the 2 row grid used in the headed to display the 2 lines (Hobby. Golfing) is replaced with a Label with a carriage return. A StackView also works.
On UWP both DataTemplates show a very similar layout.
Steps to Reproduce
Run attached project. Using a CollectionView with a DataTemplate like
Expected Behavior
CollectionView Items should not be larger than the Layout requests
Actual Behavior
CollectionView Items are too large
Basic Information
Environment
Screenshots
Android & iOS. DataTemplate on left with 2 row grid in top row of item (showing "Hobby","golfing") Same CollectionView on right, using a Label in place of a Grid. The Blue in the items is extra space in each CollectionView item. (default background color of a cell)
Same app on UWP
Reproduction Link
DataTemplateIssue.zip
Workaround
Replaced Grid in DataTemplate with a Label or StackView