-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
After #26629, the behavior of SetNeedsLayout in .NET MAUI’s iOS platform has changed. Previously, I could override SetNeedsLayout in a custom MauiView (MauiView.cs#L142) to intercept SetNeedsLayout calls propagating to the Superview. This allowed me to prevent unnecessary Arrange calls in my custom xplat layouts by controlling the layout updates.
The change in #26629 moved this logic out of SetNeedsLayout, breaking my ability to intercept and filter these calls. Additionally, I need similar control over InvalidateAncestorsMeasures, such as in MauiScrollView’s LayoutSubviews method (MauiScrollView.cs#L62). When ContentSize changes, InvalidateAncestorsMeasures triggers SetNeedsLayout up the view hierarchy, and I want to prevent this propagation in certain cases to optimize performance.
Public API Changes
- Intercept and optionally cancel SetNeedsLayout calls triggered by InvalidateMeasure, restoring the ability to customize layout updates.
- Hook into InvalidateAncestorsMeasures to control whether SetNeedsLayout propagates up the tree.
This would enable more efficient layout handling in custom controls, avoiding redundant Arrange calls.
Intended Use-Case
Intercepting SetNeedsLayout lets me skip updates when measurements are unchanged, eliminating unnecessary Arrange calls. Likewise, in MauiScrollView, blocking InvalidateAncestorsMeasures from triggering SetNeedsLayout - when ContentSize shifts but the scroll frame stays fixed - boosts scrolling performance for specific scenarios.