How to let a .NET MAUI CollectionView take up all space and distibute its items evenly?

I try to create a MAUI XAML page with MVVM which should display several groups of buttons that are arranged in columns like in the picture below, but I want the column’s width to take up all available space evenly. Also all buttons inside the columns should resize their height to take up all space based on the column with the most buttons.

To achieve this, I tried using a CollectionView (yellow) that holds all the scales (columns) and the item template of that columns has another CollectionView (blue) that holds all the buttons of that column.

I learned that I can use a GridItemsLayout in the CollectionViews with the span bound to the count of the ItemsSource. That does work for spreading the columns over the complete width but not for the CollectionView that holds the buttons inside a column (blue) as you can see in the second picture. Now all CollectionViews are sized by the number of items of the first column.

The XAML code of this state looks like this:

<CollectionView
Grid.Row="1"
Margin="8"
BackgroundColor="Yellow"
ItemsSource="{Binding ScaleList}"
VerticalOptions="FillAndExpand">
<CollectionView.ItemsLayout>
    <GridItemsLayout
        HorizontalItemSpacing="4"
        Orientation="Vertical"
        Span="{Binding ScaleList.Count}"
        VerticalItemSpacing="4" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
    <DataTemplate x:DataType="datamodels:Scale">
        <Grid RowDefinitions="Auto,*">
            <Label
                Grid.Row="0"
                Padding="4"
                BackgroundColor="Green"
                HorizontalTextAlignment="Center"
                Text="{Binding Label}" />
            <CollectionView
                Grid.Row="1"
                BackgroundColor="Blue"
                ItemsSource="{Binding ValueList}"
                VerticalOptions="FillAndExpand">
                <CollectionView.ItemsLayout>
                    <LinearItemsLayout ItemSpacing="4" Orientation="Vertical" />
                </CollectionView.ItemsLayout>
                <CollectionView.ItemTemplate>
                    <DataTemplate x:DataType="datamodels:MyValue">
                        <Frame
                            Padding="0"
                            BackgroundColor="Aquamarine"
                            CornerRadius="0">
                            <Frame.GestureRecognizers>
                                <TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:MyTestPageViewModel}}, Path=ValuePressedCommand}" CommandParameter="{Binding .}" />
                            </Frame.GestureRecognizers>
                            <Grid
                                Margin="4"
                                BackgroundColor="Red"
                                ColumnDefinitions="Auto,*">
                                <Image
                                    Grid.Column="0"
                                    Margin="4"
                                    BackgroundColor="White"
                                    HeightRequest="24"
                                    WidthRequest="24" />

                                <Label
                                    Grid.Column="1"
                                    Margin="4"
                                    Text="{Binding Name}"
                                    VerticalOptions="Center" />
                            </Grid>
                        </Frame>

                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>
        </Grid>
    </DataTemplate>
</CollectionView.ItemTemplate>

I would appreciate help to get the CollectionView use the complete vertical space and scale its items accordingly to the “most filled” column.

Maybe my approach is completely wrong and you can show up an other way to create this UI.

I also uploaded this sample project here if you want to try it out.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật