Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

ItemSizingStrategy MeasureAllItems does not work for iOS #5455

Closed
Dresel opened this issue Mar 5, 2019 · 16 comments
Closed

ItemSizingStrategy MeasureAllItems does not work for iOS #5455

Dresel opened this issue Mar 5, 2019 · 16 comments
Assignees
Labels
a/collectionview e/5 🕔 5 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛

Comments

@Dresel
Copy link
Contributor

Dresel commented Mar 5, 2019

Description

I was playing around with the CollectionView on iOS and was facing problems with uneven row height. I saw there was an ItemSizingStrategy introduced lately, but it's still behaving weird though.

Steps to Reproduce

  1. Open the DataTemplateGallery CollectionViewGallery
  2. Switch to MeasureAllItems to get the following result

  1. Swiping to right and coming back shows the following result

Expected Behavior

Items should have the same height / width when setting ItemSizingStrategy to MeasureAllItems

Actual Behavior

See above

Basic Information

  • Version with issue: master branch (50dbbcf)
  • Last known good version: -
  • Platform Target Frameworks:
    • iOS: 12.1
  • Affected Devices: iPhone 6 (iOS 12.1.4)
@Dresel Dresel changed the title ItemSizingStrategy does not work for iOS ItemSizingStrategy MeasureAllItems does not work for iOS Mar 5, 2019
@kingces95
Copy link
Contributor

Reproduces as described.

@kingces95 kingces95 added the e/5 🕔 5 label Mar 7, 2019
@Dresel
Copy link
Contributor Author

Dresel commented Apr 1, 2019

Is there any known work around (except setting height manually)? At the moment it's really useless with variable dynamic content.

@adrianknight89
Copy link
Contributor

Agreed. This needs to be given priority, imo.

@timahrentlov
Copy link

timahrentlov commented Apr 16, 2019

With regards to ItemSizingStrategy, is https://gist.github.com/hartez/7d0edd4182dbc7de65cebc6c67f72e14 current?

It is mentioned here (https://devblogs.microsoft.com/xamarin/xamarin-forms-4-0-feature-preview-an-entirely-new-point-of-collectionview/) as a way to keep track of this component.

I spent some time today trying to use CollectionView on android, and found out that ItemSizingStrategy does not work. A more prominent display of status would have saved me some grief. And time.

@pfedotovsky
Copy link

Items should have the same height/width when setting ItemSizingStrategy to MeasureAllItems

Is it correct? According to the spec, MeasureFirstItem should produce the same height/width, while MeasureAllItems should measure all items individually.

@pauldipietro pauldipietro added this to the 4.3.0 milestone Sep 5, 2019
@pauldipietro pauldipietro added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Sep 5, 2019
@adrianknight89
Copy link
Contributor

adrianknight89 commented Sep 22, 2019

MeasureFirstItem measures the first item and everything else is given the same dimension. The problem is if you scroll back and forth slowly, items on the left side of the screen change their size,

@hartez hartez removed the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Oct 10, 2019
@hartez hartez self-assigned this Oct 10, 2019
@samhouts samhouts removed this from the 4.3.0 milestone Jan 3, 2020
@samhouts samhouts added i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often and removed i/critical labels Feb 13, 2020
hartez added a commit that referenced this issue Apr 7, 2020


Check for expanding column size during layout and re-center previous items in column;
fixes #5455
@hartez hartez added the in-progress This issue has an associated pull request that may resolve it! label Apr 7, 2020
@quentinR0bert
Copy link

Hi, did we have some news about this issue ?

@ChaseFlorell
Copy link

ChaseFlorell commented Apr 30, 2020

@PureWeen @samhouts is this shipped in the latest 4.6 stable that was just shipped yesterday? The release notes say it was.

I updated my app to 4.6.0.726, and this is what I see.
Simulator Screen Shot - iPhone 11 - 2020-04-30 at 13 25 25

Once I scroll the view a little bit, then everything collapses correctly
Simulator Screen Shot - iPhone 11 - 2020-04-30 at 13 25 57

This is my xaml

<RefreshView Command="{Binding RefreshCommand}"
             IsRefreshing="{Binding IsRefreshing}">
    <CollectionView x:Name="list"
                    BackgroundColor="Transparent"
                    ItemsSource="{Binding VisibleDataObjectCollection}"
                    ItemsUpdatingScrollMode="KeepScrollOffset"
                    ItemSizingStrategy="MeasureAllItems"
                    RemainingItemsThresholdReachedCommand="{Binding LoadNextPageCommand}"
                    RemainingItemsThreshold="{StaticResource RemainingItemsThreshold}"
                    SelectionMode="Single"
                    SelectionChangedCommand="{Binding ShowDetailsCommand}"
                    SelectionChangedCommandParameter="{Binding SelectedItem, Source={RelativeSource Self}}">
        <CollectionView.Behaviors>
            <behaviors:ClearSelectedItemAfterSelectionBehavior />
        </CollectionView.Behaviors>
        <CollectionView.ItemTemplate>
            <templateSelectors:FieldListItemSelector x:DataType="models:FieldCropYearListModel">
                <templateSelectors:FieldListItemSelector.FieldWithCropTemplate>
                    <DataTemplate>
                        <StackLayout Style="{StaticResource RepeaterStack}">
                            <controlTemplates:TwoRowListItemTemplate VerticalOptions="Fill"
                                                                     HorizontalOptions="Fill"
                                                                     PrimaryText="{Binding FieldName}"
                                                                     SecondaryText="{Binding CropDescription}"
                                                                     Color="{Binding SeedColour, Converter={StaticResource ColorConverter},ConverterParameter={StaticResource White}}" />
                            <BoxView Style="{StaticResource HorizontalDivider}" />
                        </StackLayout>
                    </DataTemplate>
                </templateSelectors:FieldListItemSelector.FieldWithCropTemplate>
                <templateSelectors:FieldListItemSelector.FieldWithoutCropTemplate>
                    <DataTemplate>
                        <StackLayout Style="{StaticResource RepeaterStack}">
                            <controlTemplates:SingleRowListItemTemplate VerticalOptions="Fill"
                                                                        HorizontalOptions="Fill"
                                                                        Text="{Binding FieldName}" />
                            <BoxView Style="{StaticResource HorizontalDivider}" />
                        </StackLayout>
                    </DataTemplate>
                </templateSelectors:FieldListItemSelector.FieldWithoutCropTemplate>
            </templateSelectors:FieldListItemSelector>
        </CollectionView.ItemTemplate>
        <CollectionView.EmptyView>
            <controlTemplates:EmptyDataTemplate Text="{x:Static resx:AppResources.FieldsPage_ListEmptyMessage}" />
        </CollectionView.EmptyView>
        <CollectionView.Header>
            <ContentView Padding="3" />
        </CollectionView.Header>
        <CollectionView.Footer>
            <StackLayout Padding="6, 16">
                <Button Text="{x:Static resx:AppResources.ActivityListPage_ClearFilter}"
                        Style="{StaticResource TextOnlyButton}"
                        IsVisible="{Binding HasFiltersApplied}"
                        Command="{Binding ClearFiltersCommand}" />

                <ActivityIndicator HorizontalOptions="Center"
                                   VerticalOptions="Center"
                                   Color="{StaticResource PrussianBlue}"
                                   IsRunning="{Binding IsLoadingPage}"
                                   IsVisible="{Binding IsLoadingPage}" />
            </StackLayout>
        </CollectionView.Footer>
    </CollectionView>
</RefreshView>

@samhouts
Copy link
Member

@ChaseFlorell Can you please open a new issue? Thanks!

@ChaseFlorell
Copy link

ChaseFlorell commented Apr 30, 2020

@samhouts this appears to be the exact same issue. However, I won't be opening a new issue as I'm on my last ONE hour of this contract and I will not have any ability to do follow-up.

Maybe someone else on the team wants to follow up.
@Alex-Wang08 @kelci2017 @GhostTigerXLI

@KMWenyon
Copy link

Any updates on this?

@phimu
Copy link

phimu commented Apr 22, 2022

Still no news here?

@EnglishDave
Copy link

This is still broken on iOS. Even with ItemSizingStrategy="MeasureAllItems", it only measures the first item and then applies that height to every row.

Examp,e XAML below that exhibits this issue:

    <CollectionView
            Grid.Row="1" 
            Grid.Column="0" 
            Grid.ColumnSpan="3"
            ItemsSource="{Binding ChangeOrderItems}"
            SelectionMode="None"
            ItemSizingStrategy="MeasureAllItems"
            >
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Grid
                        ColumnSpacing="30"
                        >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Label
                            Grid.Column="0"
                            Grid.Row="0"
                            Text="{Binding Original}"
                            TextColor="{x:Static core:Colors.TitleTextColor}" />
                        <Label
                            Grid.Column="1"
                            Grid.Row="0"
                            Text="{Binding Current}"
                            TextColor="{x:Static core:Colors.TitleTextColor}" />
                        <Label
                            Grid.Column="2"
                            Grid.Row="0" 
                            Text="{Binding Change}"
                            TextColor="{x:Static core:Colors.TitleTextColor}" />
                    </Grid>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/collectionview e/5 🕔 5 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛
Projects
None yet
Development

No branches or pull requests