Skip to content

[iOS] CollectionView with header or footer has incorrect height #27808

@kubaflo

Description

@kubaflo

Description

When using a CollectionView with a HeaderTemplate or FooterTemplate, the calculated height of the CollectionView does not include the height of the header and footer. As a result, the total height of the CollectionView is incorrectly measured, leading to unexpected UI issues.

<VerticalStackLayout>
       <CollectionView>
              <CollectionView.ItemsSource>
                     <Array Type="{x:Type x:String}">
                            <x:String>item1</x:String>
                            <x:String>item2</x:String>
                            <x:String>item3</x:String>
                     </Array>
              </CollectionView.ItemsSource>
              <CollectionView.ItemTemplate>
                     <DataTemplate>
                            <Label AutomationId="{Binding .}"
                                   Text="{Binding .}"/>
                     </DataTemplate>
              </CollectionView.ItemTemplate>
              <CollectionView.HeaderTemplate>
                     <DataTemplate>
                            <BoxView HeightRequest="100"
                                          BackgroundColor="Green"/>
                     </DataTemplate>
              </CollectionView.HeaderTemplate>
              <CollectionView.FooterTemplate>
                     <DataTemplate>
                            <BoxView HeightRequest="200"
                                          BackgroundColor="Blue"/>
                     </DataTemplate>
              </CollectionView.FooterTemplate>
       </CollectionView>
</VerticalStackLayout>
Expected (Android) Actual (iOS)

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.40 SR4

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions