Xamarin.forms: [Bug] CollectionView Header, EmptyView And GridItemsLayout

Created on 25 Mar 2020  路  4Comments  路  Source: xamarin/Xamarin.Forms

Description
When I use a CollectionView with Header and EmptyView with GridItemsLayout,
the design looks bad, I think GridItemsLayout should only affect ItemTemplate and not the CollectionView object.

Steps to Reproduce

<CollectionView ItemsSource="{Binding lists}">
                <CollectionView.ItemsLayout>
                    <GridItemsLayout Orientation="Vertical" Span="3" />
                </CollectionView.ItemsLayout>
      <CollectionView.EmptyView>
                    <StackLayout>
                        <Label Text="No data!"
                       Margin="10,25,10,10"
                       FontAttributes="Bold"
                       FontSize="18"
                       HorizontalOptions="Fill"
                       HorizontalTextAlignment="Center" />
                    </StackLayout>
                </CollectionView.EmptyView>
    <CollectionView.Header>
        <StackLayout>
            <Label Text="Header"
                FontSize="Medium"
                HorizontalOptions="Center"/>
        </StackLayout>
    </CollectionView.Header>
    <CollectionView.ItemTemplate>
        <DataTemplate>
            <Label Text="{Binding .}"/>
        </DataTemplate>
    </CollectionView.ItemTemplate>
</CollectionView>

Expected Behavior
GridItemsLayout should not affect Header, EmptyView or Footer, only ItemTemplate.

Actual Behavior
GridItemsLayout affect Header, EmptyView, Footer and ItemTemplate.

Basic Information
Version with issue: vs 16.5
IDE: vs 16.5.0
Affected Devices: Android Emulator
OS: Windows 10 without hyper-V

if we remove GridItemsLayout everything works fine

collectionview Android bug

Most helpful comment

Attached repro sample.
Issue10085.zip

cv-layout-issue-small

The size of the header and EmptyView changes based on the Span value of GridItemsLayout.
ezgif-3-13f02d31e6d1

All 4 comments

@angelru Can you post some screenshots so we can see the layout you are getting?

With GridItemsLayout:
Sin t铆tulo

Without GridItemsLayout
Sin t铆tulo1

GridItemsLayout should not affect Header, EmptyView or Footer, only ItemTemplate.

@hartez @PureWeen

Attached repro sample.
Issue10085.zip

cv-layout-issue-small

The size of the header and EmptyView changes based on the Span value of GridItemsLayout.
ezgif-3-13f02d31e6d1

Any updates?

Was this page helpful?
0 / 5 - 0 ratings