I'm using CollectionView with DataTemplate
<DataTemplate x:Key="tileTemplate">
<StackLayout VerticalOptions="FillAndExpand" BackgroundColor="Red" Padding="5" x:Name="ItemContainer">
<StackLayout Padding="5" HorizontalOptions="CenterAndExpand" WidthRequest="{Binding Width, Source={x:Reference ItemContainer}}" HeightRequest="{Binding Width, Source={x:Reference ItemContainer}}">
<Image Source="{Binding LogoID}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFit" />
</StackLayout>
</StackLayout>
</DataTemplate>
<CollectionView x:Name="ItemsCollectionView" ItemsSource="{Binding Items}" ItemTemplate="{StaticResource itemsDataTemplateSelector}">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"/>
</CollectionView.ItemsLayout>
</CollectionView>
On Android they align vertically from the top:
But on IOS they align rather chaotically:
I can't figure out how to align them from the top like in Android.
--== UPDATE ==-- :
The problem is with HeightRequest of inner StackLayout
HeightRequest="{Binding Width, Source={x:Reference ItemContainer}}"
(same result if you use OnSizeAllocated)
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
HeightRequest = Width;
}
How to keep proportions and prevent tiles from popping on IOS is still opened question.