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
21.96k stars 1.7k forks source link

[WinUI] [UIKit] CollectionView Items do not resize if the inner content changes. #13451

Open drasticactions opened 1 year ago

drasticactions commented 1 year ago

Description

If you modify an existing CollectionView item on iOS, Catalyst, or WinUI the outer cell does not resize to reflect the new content. This should similar, if not the same, as https://github.com/dotnet/maui/issues/12118, but with a simple reproduction step (If that's the case, IMO, I would close that issue and redirect it to this one, since it's broader in scope).

For WinUI in my sample, the content doesn't directly overlap, rather there are gaps present between the cells as you add or remove them. With enough changes of the inner cells and their orders, you can cause the contents to overlap.

https://user-images.githubusercontent.com/898335/220037568-884189f6-ff99-4169-a663-a4e7712871d4.mp4

Steps to Reproduce

  1. Clone https://github.com/drasticactions/MauiRepros/tree/main/MauiCollectionViewResize
  2. Run the sample

Link to public reproduction project repository

https://github.com/drasticactions/MauiRepros/tree/main/MauiCollectionViewResize

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Windows, macOS

Affected platform versions

All affected platform versions.

Did you find any workaround?

Somehow force the window or control to resize. On Windows/Mac you can resize the window, but that's not possible on iPhone.

For WinUI, ListView does not seem to suffer from this overlap issue, and it spaces its items correctly between them. On iOS/Catalyst the cells still don't resize, but adding a new one causes the previous cells to resize, "fixing" the issue.

Relevant log output

No response

ghost commented 1 year 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.

Zhanglirong-Winnie commented 1 year ago

Verified this issue with 17.6 Preview (17.6 build 1539). Can repro on macOS with sample project. MauiRepros-main.zip 13451 macOS

eengstroem commented 1 year ago

I believe I'm experiencing the same issue here. It seems to work with android. The link has a link to a reproduction repo.

eengstroem commented 1 year ago

Is there some kind of workaround?

Pughgramming commented 4 months ago

Is there an update on this? I've seen that there is a fix incoming for a similar issue regarding the header here, but this is more related to the items.

Baraiboapex commented 2 months ago

Is there a way to force the whole outer cell of the collection view to redraw via triggering invalidation as shown in the workaround that @Pughgramming pointed out?

[Update]

I did try invalidating the whole collection view using the following code:

MainCollectionView.InvalidateMeasureNonVirtual(InvalidationTrigger.Undefined);

But this did not seem to work either.

Any help on how to fix this would be much appreciated. Thanks.

konradzuse commented 2 months ago

In our case we're loading images asynchronously, so the cell resizes only once the images have been populated. The only workaround is to rotate the device so that the cell is redrawn.

I've just updated to 8.0.60 but the issue remains.

Baraiboapex commented 2 months ago

@konradzuse

Yeah, I did the same thing for our application. and its still not working either. Here is a link to a repo that I am using to reproduce this problem on iOS, btw: https://github.com/Baraiboapex/Armory2/tree/master/Armory2

It would be great if this could be fixed so that we can release our application.

Baraiboapex commented 2 months ago

Does anybody know of any libraries that can be used in place of this? I'm just wondering. Maybe this won't be such a show stopper if we can find something.