Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CollectionView][iOS] CollectionView with a CollectionView with LinearItemsLayout set to Horizontal in its Header fills the CollectionView with blank space #27150

Open
Vetle444 opened this issue Jan 15, 2025 · 3 comments · May be fixed by #27226
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-cv2 i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/iOS 🍎 regressed-in-9.0.21 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@Vetle444
Copy link

Description

If you have a default CollectionView, putting a CollectionView that has <LinearItemsLayout Orientation="Horizontal" /> in its header fills the outer CollectionView with a lot of blank space. I'm not sure if this is good practice, however this worked in .NET MAUI 9.0.10 (Did not test 9.0.20).

Code:

<CollectionView>
        
        <CollectionView.ItemsSource>
            <x:Array Type="{x:Type x:String}">
                <x:String>First</x:String>
                <x:String>Second</x:String>
                <x:String>Third</x:String>
            </x:Array>
        </CollectionView.ItemsSource>
        
        <CollectionView.Header>
            <CollectionView>
                <CollectionView.ItemsLayout>
                    <LinearItemsLayout Orientation="Horizontal" />
                </CollectionView.ItemsLayout>
                
                <CollectionView.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>First</x:String>
                        <x:String>Second</x:String>
                        <x:String>Third</x:String>
                    </x:Array>
                </CollectionView.ItemsSource>
                
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Label Text="{Binding .}" />
                    </DataTemplate>
                </CollectionView.ItemTemplate>
                
            </CollectionView>
        </CollectionView.Header>

        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Label Text="{Binding .}" />
            </DataTemplate>
        </CollectionView.ItemTemplate>
        
    </CollectionView>

Image

As you can see, the CollectionView's items is pushed far down, however, the header that has the CollectionView displays the text correctly.

Steps to Reproduce

  1. Create a new ContentPage
  2. Put the code above as the content

Link to public reproduction project repository

No response

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.10 SR1

Affected platforms

iOS

Affected platform versions

iOS >=17.5

Did you find any workaround?

Rewriting to use BindableLayout together with HorizontalStackLayout and ScrollView

Relevant log output

@Vetle444 Vetle444 added the t/bug Something isn't working label Jan 15, 2025
@RoiChen001 RoiChen001 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed platform/iOS 🍎 i/regression This issue described a confirmed regression on a currently supported version labels Jan 16, 2025
@RoiChen001
Copy link

I can repro this issue at iOS platform on the latest 17.13 Preview 2.1(9.0.30), but it works fine at 9.0.10.

@StephaneDelcroix StephaneDelcroix added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Jan 16, 2025
@StephaneDelcroix StephaneDelcroix added this to the Backlog milestone Jan 16, 2025
@PureWeen PureWeen modified the milestones: Backlog, .NET 9 SR3.1 Jan 16, 2025
@rmarinho
Copy link
Member

This happens on cv1 and cv2 on main right now.

@kubaflo kubaflo linked a pull request Jan 20, 2025 that will close this issue
@PureWeen PureWeen moved this from Todo to In Progress in MAUI SDK Ongoing Jan 22, 2025
@kubaflo
Copy link
Contributor

kubaflo commented Jan 23, 2025

Hi! @Vetle444 could you please attach a sample to a project that works>. I cannot reproduce working behavior on net 9.0.10

With the following MainPage:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiSandbox.MainPage">

    <CollectionView>

        <CollectionView.ItemsSource>
            <x:Array Type="{x:Type x:String}">
                <x:String>First</x:String>
                <x:String>Second</x:String>
                <x:String>Third</x:String>
            </x:Array>
        </CollectionView.ItemsSource>

        <CollectionView.Header>
            <CollectionView>
                <CollectionView.ItemsLayout>
                    <LinearItemsLayout Orientation="Horizontal"/>
                </CollectionView.ItemsLayout>

                <CollectionView.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>First</x:String>
                        <x:String>Second</x:String>
                        <x:String>Third</x:String>
                    </x:Array>
                </CollectionView.ItemsSource>

                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Label Text="{Binding .}"/>
                    </DataTemplate>
                </CollectionView.ItemTemplate>

            </CollectionView>
        </CollectionView.Header>

        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Label Text="{Binding .}"/>
            </DataTemplate>
        </CollectionView.ItemTemplate>

    </CollectionView>
</ContentPage>

The app is not loading for me

@PureWeen PureWeen modified the milestones: .NET 9 SR3.1, .NET 9 SR4 Jan 28, 2025
@PureWeen PureWeen added p/0 Work that we can't release without regressed-in-9.0.21 labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-cv2 i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/iOS 🍎 regressed-in-9.0.21 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

6 participants