maui icon indicating copy to clipboard operation
maui copied to clipboard

[MacOS, iOS] ListView and CollectionView on the fly changes don't change the size of the layout

Open NonameMissingNo opened this issue 2 years ago • 17 comments

Description

We have an application that requires elements inside the listview / collectionview to open if it's the selected one, and close when it's not.

It works perfectly fine on Windows, and Android, but the Apple ecosystem does not handle it well.

ForceUpdateSize in ListViews doesn't seem to effect things CollectionView: CollectionView ListView: ListView .

Expected (Windows): image

Steps to Reproduce

Create a new app. Put a ListView in it, with a Button. Set a Clicked event to the Button. Change the HeightRequest, or in the case of a Grid, the RowDefinitions with the Clicked event. Run the app. Click on an element. CollectionView: The selected element expands behind the other elements ListView: The selected element expans in front of the other elements.

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

iOS 15, MacOS 14

Did you find any workaround?

No response

Relevant log output

No response

NonameMissingNo avatar Jun 12 '22 14:06 NonameMissingNo

@NonameMissingNo could you mind share the repro project to help us repro this issue?

kristinx0211 avatar Jun 14 '22 10:06 kristinx0211

Hi @NonameMissingNo. 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 Jun 14 '22 10:06 ghost

Hey there @kristinx0211, sorry for the delay. Here's the repro file: MauiApp10 (2).zip

NonameMissingNo avatar Jun 14 '22 13:06 NonameMissingNo

verified repro on IOS 15.4 as above describe.

kristinx0211 avatar Jun 15 '22 07:06 kristinx0211

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Aug 30 '22 14:08 ghost

This item should be declared as pretty high priority, since this is not an issue in Android it clearly is an issue with the native control used in iOS for the collectionview. This makes any chat based application that support rich messaging completely useless in iOS. There must be a better control to use under the hood that supports dynamic resizing. Personally I would sacrifice speed to have the UI do what I want.

LennoxP90 avatar Oct 26 '22 19:10 LennoxP90

I agree that this should be a high priority issue. It seems like a basic functionality for a very common control.

mlancione avatar Oct 26 '22 20:10 mlancione

Agreed, we are also experiencing the same issue and it is causing our app functionality to fail on iOS when trying to expand an item in the ListView. Is there any workaround?

petrakritzinger avatar Nov 08 '22 09:11 petrakritzinger

I'm having the same issue. Should definitely be a higher priority for a control that's used as much as Listview / collectionview

WebGoose avatar Nov 08 '22 09:11 WebGoose

#if IOS || MACCATALYST if ((levelcollection.Handler.PlatformView as UIView).Subviews[0] is UICollectionView Table) { if (Table.CollectionViewLayout is UICollectionViewFlowLayout Layout) { Layout.InvalidateLayout(); } } #endif Where the name of levelcollection is your CollectionView (Add it to where you're expanding it)

NonameMissingNo avatar Nov 08 '22 11:11 NonameMissingNo

NonameMissingNo's workaround unfortunately does not work for me. Also tried the workaround suggested by EPS-Lac in #8820. This works in a very simple scenario, but not on mine where I have a listview within another listview.

petrakritzinger avatar Nov 08 '22 12:11 petrakritzinger

Is there any progress on this Microsoft?

LennoxP90 avatar Nov 29 '22 04:11 LennoxP90

Any updates?

danielftz avatar Dec 11 '22 08:12 danielftz

Disappointed this had been pushed back so long ;(

darrylayers avatar Apr 29 '23 03:04 darrylayers

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on iOS platform with above project MauiApp10 (2).zip

jinxinjuan avatar Jun 29 '23 05:06 jinxinjuan

We've finally found a workaround for this issue!

Instead of ListView/CollectionView, use a (Vertical/Horizontal)StackLayout with BindableLayout attached properties.

If you need scrolling, wrap the StackLayout in an additional ScrollView.

stefanpirkl avatar Oct 26 '23 16:10 stefanpirkl

This issue makes me doubt MAUI as a platform. It's core functionality to have a working ListView and the iOS implementation sucks. The title is slightly wrong, the size does change, the user just has to turn their phone sideways to get it to redraw the layout and then turn it back to the original orientation - then it looks like it's supposed to. It's absolutely ridiculous that this bug has not been fixed for 1.5 years.

johbake avatar Jan 13 '24 16:01 johbake

This workaround worked for me as follows:

Whether you choose to use code behind or MVVM, calling the RefreshData() on the collectionview every time you need your item to change or redraw. Also, it might be more efficient to call RefreshItem method on the CollectionView.

Here's my sample: private void Expander_ExpandedChanged(object sender, CommunityToolkit.Maui.Core.ExpandedChangedEventArgs e) { notesCollectionView.RefreshData(); }

MohammedBen avatar Mar 21 '24 17:03 MohammedBen