dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.22k stars 1.75k forks source link

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

Open NonameMissingNo opened 2 years ago

NonameMissingNo commented 2 years ago

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

kristinx0211 commented 2 years ago

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

ghost commented 2 years ago

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.

NonameMissingNo commented 2 years ago

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

kristinx0211 commented 2 years ago

verified repro on IOS 15.4 as above describe.

ghost commented 2 years ago

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.

LennoxP90 commented 2 years ago

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.

mlancione commented 2 years ago

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

petrakritzinger commented 2 years ago

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?

WebGoose commented 2 years ago

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

NonameMissingNo commented 2 years ago

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)

petrakritzinger commented 2 years ago

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.

LennoxP90 commented 1 year ago

Is there any progress on this Microsoft?

danielftz commented 1 year ago

Any updates?

darrylayers commented 1 year ago

Disappointed this had been pushed back so long ;(

jinxinjuan commented 1 year ago

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

stefanpirkl commented 1 year ago

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.

johbake commented 10 months ago

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.

MohammedBen commented 7 months ago

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(); }