[iOS] CollectionView fails to render items when frame grows from zero post-mount (regression of #30953 in .NET 10)
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
CollectionViewHandler2 (the default iOS handler in .NET 10) fails to render items when the underlying UICollectionView
is mounted with a zero-size frame and then later grows. This is the exact symptom reported in #30953
(https://github.com/dotnet/maui/issues/30953), which was marked closed via a fix that shipped to .NET 9 SR10 (PR
#30978 (https://github.com/dotnet/maui/pull/30978)). The fix was not forward-ported to .NET 10 — the regression is
back on MAUI 10.0.60.
Tracing the .NET 10 source (src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs):
- LoadView creates the UICollectionView with CGRect.Empty.
- GetDesiredSize has a force-layout fallback for pre-mount measurement, but only fires when collectionView.Window ==
null — once the view is mounted with a zero frame, this path is bypassed forever.
- ViewWillLayoutSubviews re-invalidates only when NeedsCellLayout is explicitly set or ContentSize changes. Neither
happens, because items were never realized to begin with.
The result: items are never realized, even though the parent layout has grown to give the CollectionView a non-zero
frame.
Steps to Reproduce
Minimal pattern:
1. Create a Grid with a RowDefinition whose Height is bound to a property starting at 0.
2. Place a CollectionView in that row, with HeightRequest bound to the same (or another zero-starting) property.
3. On a button tap, update the property to a non-zero value.
Expected: items render once the row grows.
Actual: the CollectionView is empty on iOS in .NET 10 (Handler2). Same code works on .NET 9 (legacy handler) and on
iOS in .NET 10 if the legacy handler is registered explicitly.
The pattern is the same one in #30953's repro project:
https://github.com/telerik/ms-samples/tree/main/Maui/CollectionViewItemsSourceNet10Issue. Reproduces identically on
MAUI 10.0.60.
Link to public reproduction project repository
Same repro as #30953: https://github.com/telerik/ms-samples/tree/main/Maui/CollectionViewItemsSourceNet10Issue (update
package versions to 10.0.60 to reproduce on .NET 10).
Version with bug
10.0.60 (also reproduced on 10.0.41)
Is this a regression from previous behavior?
Yes
Last version that worked well
9.0.90 SR9 (per #30953, and confirmed against the legacy CollectionViewHandler on .NET 10 — fix from PR #30978
evidently didn't forward-port to .NET 10).
Affected platforms
iOS, Mac Catalyst (per #30953)
Affected platform versions
iOS 26.4
Did you find any workaround?
Yes — register the legacy CollectionViewHandler for the affected CollectionView (matches the workaround in the
original #30953):
#if IOS
builder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler();
});
#endif
To scope the opt-out to a single control instead of every CollectionView in the app, register against a thin subclass:
public class MyCollectionView : CollectionView { }
handlers.AddHandler();
Both restore correct rendering. Handler2 remains active for all other CollectionView instances when scoped via
subclass.
Relevant log output
No exceptions or warnings — the CollectionView simply renders empty
Contributor guide
Research direction
Start in src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs and trace LoadView, GetDesiredSize, and ViewWillLayoutSubviews. Compare the missing .NET 10 behavior with the fix described in PR #30978, then run the CollectionViewItemsSourceNet10Issue reproduction on MAUI 10.0.60. Done means items render after the CollectionView grows from a zero-size frame on iOS and Mac Catalyst without requiring the legacy handler.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, ios
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100