maui icon indicating copy to clipboard operation
maui copied to clipboard

[iOS] BindableLayout or a CollectionView in a CollectionView display bug

Open jeffgoku opened this issue 1 year ago • 10 comments

Description

After modified(add or remove) items in the inner ItemsSource the inner Layout WONT update the bounds or just display for first item.

When the outter CollectionView is long enough to be scrolled, the inner CollectionView will be updated incorrectly, all the inner CollectionView will only display the first item

Only for iOS, android is ok

Steps to Reproduce

// outter CollectionView
<CollectionView ItemsSource="{Binding Items}">
    <CollectionView.ItemTemplate>
        <DataTemplate>
             <local:InnerView BindingContext="{Binding}" />
        </DataTempalte>
   </CollectionView.ItemTemplate>
</CollectionView>

// InnerView
<Border>
   // no matter this is BindableLayout or CollectionView, the same result
    <VerticalStackLayout BindableLayout.ItemsSource="{Binding Items}">
      <BindableLayout.ItemTemplate>
         <DataTemplate>
             <SwipeView>
                    <Grid ColumnDefinitions="*" Padding="6, 2">
                        <VerticalStackLayout Spacing="1">
                            <Label Text="{Binding Title}"/>
                            <Label FontSize="10" Padding="2,0,0,0" TextColor="Gray" Text="{Binding Time}"/>
                        </VerticalStackLayout>
                    </Grid>
             </SwipeView>
         </DataTemplate>
      </BindableLayout.ItemTemplate>
    </VerticalStackLayout>
</Border>
  1. Use above UI
  2. Add enough items to InnerView and OutterView for the outter view to be able to scroll
  3. Scroll the OutterView

Expected Result: every item is displayed Actual Result: only the first item of the inner view will be displayed

Link to public reproduction project repository

CollectionView bug

Version with bug

7.0.100

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17 simulator

Did you find any workaround?

No response

Relevant log output

No response

jeffgoku avatar Nov 07 '23 04:11 jeffgoku

Can you create a sample repro showing this? Having the actual code implemented into a deployable project would make this easier to debug and for everyone to verify.

drasticactions avatar Nov 07 '23 04:11 drasticactions

Hi @jeffgoku. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Nov 07 '23 04:11 ghost

Repro added, CollectionView and scroll both not working as expected.

jeffgoku avatar Nov 07 '23 08:11 jeffgoku

Hi @jeffgoku. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Nov 07 '23 19:11 ghost

I am using VS mac, how can I install the latest version?

jeffgoku avatar Nov 08 '23 02:11 jeffgoku

Hello,

I meet the same issue with a build on Azure Pipeline:

  • Installed SDK Version: 8.0.100-rc.2.23502.2
  • microsoft.net.sdk.ios version 17.0.8477-net8-rc2.2
  • Installed Microsoft.Maui.Sdk.net7 version 7.0.101

(Build on .net7)

The CollectionView doesn't work as expected on iOS (but works on Android). The layout is not updated, and there is an issue with the virtualization (some data won't display when scrolling)

Yokaichan avatar Nov 12 '23 09:11 Yokaichan

Hi,

Someone knows a workaround about this bug ? I didn't find a wayt to refresh the layout by my side.

Yokaichan avatar Nov 23 '23 10:11 Yokaichan

I'm also having a similar problem. The size of the CollectionView does not change when the number of elements in the BindableLayout inside the CollectionView changes.

cat0363 avatar Dec 28 '23 04:12 cat0363

I've finally found a workaround by:

  • Add a property in my viewmodel to the CollectionView
  • Populate this property when the control is loaded (with Loaded callback)
  • In my command that add / remove an item, I "manually" change the ItemSizingStrategy to force an update:

MainThread.BeginInvokeOnMainThread(() => { TransportsCollectionView.ItemSizingStrategy = ItemSizingStrategy.MeasureFirstItem; TransportsCollectionView.ItemSizingStrategy = ItemSizingStrategy.MeasureAllItems; });

Yokaichan avatar Jan 31 '24 14:01 Yokaichan

Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20). Can repro it with sample project

kevinxufei avatar Apr 12 '24 08:04 kevinxufei