ibocon
ibocon

Reputation: 1494

Xamarin.Forms.CollectionView shows different size then what I set when ItemsLayout is GridItemsLayout

Screenshot

Only items in first row shows different size then other items. However I set same size to all items in XAML. It only happens on Android.

    <CollectionView
        HorizontalOptions="FillAndExpand"
        HeightRequest="100"
        ItemsSource="{Binding Items}"
        SelectionMode="Single">

        <CollectionView.ItemsLayout>
            <GridItemsLayout
                Orientation="Vertical"
                Span="4"
                HorizontalItemSpacing="10"
                VerticalItemSpacing="10"/>
        </CollectionView.ItemsLayout>
                                    
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <StackLayout>
                    <Image
                        WidthRequest="50"
                        HeightRequest="50"
                        Source="{local:ImageResource CollectionView.Image.png}"/>
                    <Label
                        Text="{Binding Title}"
                        HorizontalTextAlignment="Center"
                        VerticalTextAlignment="Center" />
                </StackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

Github

Upvotes: 0

Views: 519

Answers (1)

Cherry Bu - MSFT
Cherry Bu - MSFT

Reputation: 10346

I download your sample to test, I can not run your sample, I create new project and upload one sample, you can take a look:

https://github.com/CherryBu/collectionsample1

This is the screenshot:

enter image description here

Upvotes: 1

Related Questions