Skip to content

Items in CollectionView using GridItemsLayout not sized correctly (content gets clipped)  #16115

Closed as not planned

Description

Description

Items inside a GridItemsLayout with Span=1 will grow when the containing window is resized.
But they won't shrink when window gets smaller. Thus the items in the CollectionView are clipped.

Remarks:

  • In our full app we will change GridItemsLayout.Span according to the available space for our CollectionView.
  • When GridItemsLayout.Span is at least set to 2 items will not be clipped.

Initial layout:

image

Resized window (wider):
image

Resized window (smaller -> clipped items):

image

Steps to Reproduce

Please clone the attached repro repository and start the application: https://github.com/s-beltz/CollectionViewRepro

Basically this is the XAML producing the error:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiCollectionViewApp.MainPage"
             x:Name="thisPage">
    <ContentPage.Resources>
        <!-- Changing Span to anything greater than 1 will work -->
        <GridItemsLayout x:Key="TilesLayout"
                         Span="1"
                         Orientation="Vertical"
                         HorizontalItemSpacing="10"
                         VerticalItemSpacing="10" />
        <DataTemplate x:Key="TileTemplate">
            <Grid Margin="20"
                  BackgroundColor="Gainsboro"
                  VerticalOptions="Fill"
                  HeightRequest="100">
                <Label HorizontalOptions="Center"
                       VerticalOptions="Center"
                       Text="{Binding Mode=OneWay}" 
                       FontSize="Large"/>
            </Grid>
        </DataTemplate>
    </ContentPage.Resources>
    <Grid>
        <CollectionView BackgroundColor="LightBlue"
                        HorizontalOptions="Fill"
                        VerticalOptions="Fill"
                        ItemsSource="{Binding Path=Tiles, Mode=OneWay, Source={x:Reference thisPage}, TargetNullValue={x:Null}, FallbackValue={x:Null}}"
                        ItemTemplate="{StaticResource TileTemplate}"
                        ItemsLayout="{StaticResource TilesLayout}"
                        ItemSizingStrategy="MeasureAllItems"
                        SelectionMode="Single" />
    </Grid>
</ContentPage>

Link to public reproduction project repository

https://github.com/s-beltz/CollectionViewRepro

Version with bug

7.0.92/7.0.100

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows 11

Did you find any workaround?

Unfortunately not.
In our full app we already handle SizeChanged-events and will change the Span-property according to the available space.
Trying to manipulate the CollectionView or GridItemsLayout instance did not help.
But we are willing to implement any known workaround available... ;-)

Relevant log output

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area-controls-collectionviewCollectionView, CarouselView, IndicatorViewarea-layoutStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterplatform/windows 🪟s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions