xamarin.formsuwpcollectionviewitemtemplate

CollectionView issue mixing grouping with GridItemsLayout


I'm trying to implement a Xamarin Forms CollectionView using Grouping and GridItemsLayout vertical mode and Span="2". I make the grouping work without problems, but when I add the GridItemsLayout with the Span set to 2 columns, it does not behave as it should. Still showing the collection as 1 column.

                <CollectionView
                    Grid.Row="1"
                    IsVisible="{Binding VisibleCollection}"
                    IsGrouped="True"
                    ItemsSource="{Binding Accounts}">
                    <CollectionView.GroupHeaderTemplate>
                        <DataTemplate>
                            <Label
                                FontSize="16"
                                Text="{Binding Name}" />
                        </DataTemplate>
                    </CollectionView.GroupHeaderTemplate>

                    <CollectionView.ItemsLayout>
                        <GridItemsLayout
                            Orientation="Vertical"
                            Span="2"
                            VerticalItemSpacing="10" />
                    </CollectionView.ItemsLayout>
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Label BackgroundColor="Red" Text="TEST" />
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>

Label "TEST" still showing in 1 single column, and I want it to be shown as 2 columns:

TEST TEST

instead of:

TEST

TEST

Anyone knows how I can make it possible with GridItemsLayout? btw, this issue is happenning on UWP


Solution

  • The problem comes when the collection view is initially "hide" and switching visibility.

    Xamarin forms issue: https://github.com/xamarin/Xamarin.Forms/issues/9079