Xamarin.forms: [Bug] [CollectionView] [Xamarin.forms] item will be centered when there is only one item

Created on 11 Jul 2019  路  19Comments  路  Source: xamarin/Xamarin.Forms

Description

When i use collection view which span count is 3, it works fine except when itemSource has only one Item. the only one item displays in the center of the collectionView, but i hope it can displayed in the left.

Steps to Reproduce

  1. use CollectionView in Xamarin.forms
  2. 2.
<CollectionView ItemsSource="{Binding ItemsSource}"
                HorizontalOptions="StartAndExpand"
                VerticalOptions="FillAndExpand">
    <CollectionView.ItemsLayout>
        <GridItemsLayout HorizontalItemSpacing="15"
                         Orientation="Vertical"
                         Span="3"
                         VerticalItemSpacing="15" />
    </CollectionView.ItemsLayout>
    <CollectionView.ItemTemplate>
        <DataTemplate>
            // Template
        </DataTemplate>
    </CollectionView.ItemTemplate>
</CollectionView>
  1. make ItemsSource have only one item

Expected Behavior

CollectionView item shows in the left

Actual Behavior

CollectionView item shows in the Center

Basic Information

  • Version with issue: 4.1.0.555618

ScreenShot

image
image

Demonstrates

https://github.com/micro1226/CollectionDemoForXamarin.git

collectionview 4 in-progress iOS 馃崕 bug

Most helpful comment

3 and a half month and the bug in the same place.

All 19 comments

@micro1226 Can you please attach a small project that demonstrates this issue? Thanks!

@micro1226 Can you please attach a small project that demonstrates this issue? Thanks!

Hi, i edited my issue. added ScreenShot and Demonstrates
Thanks

Thanks for the repro sample!. Verified. With more than one element (can be 2, 3, 4, etc.) the alignment is correct (aligned the left). With a single element appears centered.

@jsuarezruiz any explanation on why it is switching between backlog and Todo

This is like FlexLayout meets CollectionView. @micro1226 If your data source is small, you might want to stick to FlexLayout for this for now.

Any updates on this or workarounds? Generating and hiding a faux element to ensure more than 1 element when on iOS?

Can confirm this bug. Seems to only affect iOS. I'm on 4.3.0.991221.

Any updates on this or workarounds? Generating and hiding a faux element to ensure more than 1 element when on iOS?

i used telerik listview to solve this problem temporarily

3 and a half month and the bug in the same place.

Xamarin Forms 4.5.0.356 bug still here.
Any news or update for this issue?

Any workaround on this?

The only "workaround" I'll find is to add one item with opacity=0 if I have only one item in my collection.

Will you fix it in the future? This bug is common and needs to be fix.

Hi Team,
Still I am facing the issue in latest version 4.6.726

Same as @dhanaraj94, have updated my code to use the latest release but still see the same issue (single item groups getting centered). Also, I have now noticed issues with item sizing I do not have when not using grouping. I do not know if this is a new bug in 4.6 or an existing one that I have not noticed as I have not been using grouping. Will report that separately once confirmed.

The same as @follesoe and @dhanaraj94

I'm still experiencing the issue with the latest Xamarin.Forms (version 4.8.0.1269). I have 2 columns and I use grouping also.

I also have this issue. I'm using 2 columns with grouping (version 4.8.0.1451)

@tamasszadvari @doberman-ch The original issue didn't involve grouping - I think you might be experiencing a similar bug with a different cause. Can you open a new issue (with some info on your datasource, how you are grouping, your templates, and maybe some screenshots or a repro project)?

Thanks.

Was this page helpful?
0 / 5 - 0 ratings