maui
maui copied to clipboard
[iOS] BindableLayout or a CollectionView in a CollectionView display bug
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>
- Use above UI
- Add enough items to InnerView and OutterView for the outter view to be able to scroll
- 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
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
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.
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.
Repro added, CollectionView and scroll both not working as expected.
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.
I am using VS mac, how can I install the latest version?
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)
Hi,
Someone knows a workaround about this bug ? I didn't find a wayt to refresh the layout by my side.
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.
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; });
Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20). Can repro it with sample project