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

[iOS, MacCatalyst] CarouselView sizing issue when nested in StackLayout #12911

Open
AlexeyStarkov opened this issue Jan 25, 2023 · 7 comments
Open
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter delighter-sc layout-stack migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@AlexeyStarkov
Copy link

AlexeyStarkov commented Jan 25, 2023

Description

The size of CarouselView is calculated wrong when it's nested in StackLayout. It seems like CarouselView size is constrained by page (or even screen) size instead of the parent element's size. It works well on Android. MacCatalyst is also affected.

Here is a code of a sample page demonstrating the issue:

     <Grid RowDefinitions="*, *, *, *">
        <Label Grid.Row="0" Text="Row 0"/>

        <StackLayout Grid.Row="1">
            <CarouselView x:Name="Carousel">
                <CarouselView.ItemTemplate>
                    <DataTemplate>
                        <Border Margin="10" BackgroundColor="Grey">
                            <Label TextColor="Red" Text="{Binding .}" />
                        </Border>
                    </DataTemplate>
                </CarouselView.ItemTemplate>
            </CarouselView>

            <BoxView HeightRequest="20" Color="Purple"/>
        </StackLayout>

        <Label Grid.Row="2" Text="Row 2" />
        <Label Grid.Row="3" Text="Row 3" />
    </Grid>

Screenshot 2023-01-26 at 00 20 23

Screenshot 2023-01-26 at 00 20 49

I didn't test it on Windows and other platforms like Tizen/Linux.

Side note: My assumption is that the there is some problem related to ItemsView because similar bugs for CollectionView has been reported and both CollectionView and CarouselView are derived from ItemsView.

Steps to Reproduce

  1. Open reproduction project
  2. Launch the application on iOS or MacCatalyst

Link to public reproduction project repository

https://github.com/AlexeyStarkov/MAUI_CarouselView_Sizing_Issue
#12911 (comment)

Version with bug

.NET 6.0,
.NET 7.0
.NET 8.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

iOS 16.2, macOS Ventura 13.1

Did you find any workaround?

No response

Relevant log output

No response

@AlexeyStarkov AlexeyStarkov added the t/bug Something isn't working label Jan 25, 2023
@AlexeyStarkov AlexeyStarkov changed the title [iOS, MacCatalyst] Carousel View sizing issue when nested in StackLayout [iOS, MacCatalyst] CarouselView sizing issue when nested in StackLayout Jan 25, 2023
@jsuarezruiz jsuarezruiz added platform/iOS 🍎 area-controls-collectionview CollectionView, CarouselView, IndicatorView area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-stack labels Jan 26, 2023
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jan 26, 2023
@ghost
Copy link

ghost commented Jan 26, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@jinxinjuan jinxinjuan added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Jun 8, 2023
@jinxinjuan
Copy link

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Can repro on iOS and Maccatalyst platform with sample project.
MAUI_CarouselView_Sizing_Issue

@dotMorten
Copy link
Contributor

I'm seeing the same thing - both .NET 7 and .NET 8 Preview 5. Haven't found a good way to work around this.

@evgenyKozlov1996
Copy link

The same issue verified in .NET 8.0.3

@willcorum
Copy link

Same in 8.0.6. Unless you specify a height on the carousel and the data template item the carousel tries to occupy all the vertical space. Android is not affected. Setting a height doesn't allow the control to resize itself based on variable text content. Pretty frustrating. You can replicate this by removing the height settings from the HorizontalTemplateLayoutPage.xaml view in the demo. https://github.com/dotnet/maui-samples/tree/main/8.0/UserInterface/Views/CarouselViewDemos

@maxiking01
Copy link

Same on 8.0.7 . The problem only occurs on iOS. Did not test on MacCatalyst. On Android CarouselView works properly.

@samhouts samhouts added partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels May 21, 2024
@coop-tim
Copy link

coop-tim commented Jul 1, 2024

+1 having to put fixed height on carousels because of this bug is very frustrating

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 area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter delighter-sc layout-stack migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants