Search code examples
collectionviewmaui

MAUI CollectionView Span Property Bug


MAUI, VS17.4 pr1, Windows. I Set CollectionView Span value to 3, So if I have only 1 or 2 objects, the CollectionView will display nothing. I attached a runable project on my Synology.

BugProject

BTW, ScrollBar doesn't show in the View.

Whole XAML Page:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="MauiApp1.VerticalListDynamicSizeItemsPage"
         Title="Vertical list (dynamic item sizing)">
<StackLayout>
    <Button TextColor="Wheat"
            Text="Add New "
            Command="{Binding AddCommand}" />
    <Button TextColor="Wheat"
            Text="Delete New "
            Command="{Binding DeleteCommand}" />
    <CollectionView HorizontalOptions="Start"
                    HorizontalScrollBarVisibility="Always"
                    ItemsLayout="VerticalGrid, 3"
                    ItemsSource="{Binding Monkeys}"
                    VerticalScrollBarVisibility="Always">
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Grid Padding="10">
                    <BoxView WidthRequest="100"
                             HeightRequest="100"
                             Color="Red" />
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</StackLayout>

Solution

  • It's a bug, I'll create a github issue.