diff --git a/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs index 62116b468264..a22a10b66475 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs @@ -46,6 +46,16 @@ protected override void Dispose(bool disposing) _footerViewFormsElement.MeasureInvalidated -= OnFormsElementMeasureInvalidated; } + if (_headerUIView is MauiView hv) + { + hv.LayoutChanged -= HeaderViewLayoutChanged; + } + + if (_footerUIView is MauiView fv) + { + fv.LayoutChanged -= FooterViewLayoutChanged; + } + _headerUIView = null; _headerViewFormsElement = null; _footerUIView = null; @@ -105,6 +115,11 @@ internal void UpdateFooterView() UpdateSubview(ItemsView?.Footer, ItemsView?.FooterTemplate, FooterTag, ref _footerUIView, ref _footerViewFormsElement); UpdateHeaderFooterPosition(); + + if (_footerUIView is MauiView mv) + { + mv.LayoutChanged += FooterViewLayoutChanged; + } } internal void UpdateHeaderView() @@ -112,8 +127,14 @@ internal void UpdateHeaderView() UpdateSubview(ItemsView?.Header, ItemsView?.HeaderTemplate, HeaderTag, ref _headerUIView, ref _headerViewFormsElement); UpdateHeaderFooterPosition(); + + if(_headerUIView is MauiView mv) + { + mv.LayoutChanged += HeaderViewLayoutChanged; + } } + internal void UpdateSubview(object view, DataTemplate viewTemplate, nint viewTag, ref UIView uiView, ref VisualElement formsElement) { uiView?.RemoveFromSuperview(); @@ -239,5 +260,15 @@ internal void UpdateLayoutMeasurements() if (_footerViewFormsElement != null) HandleFormsElementMeasureInvalidated(_footerViewFormsElement); } + + void HeaderViewLayoutChanged(object sender, EventArgs e) + { + HandleFormsElementMeasureInvalidated(_headerViewFormsElement); + } + + void FooterViewLayoutChanged(object sender, EventArgs e) + { + HandleFormsElementMeasureInvalidated(_footerViewFormsElement); + } } } \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/HeaderShouldNotCollapseWithItems.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/HeaderShouldNotCollapseWithItems.png new file mode 100644 index 000000000000..02de2114edb5 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/HeaderShouldNotCollapseWithItems.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue12429.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue12429.xaml new file mode 100644 index 000000000000..ea45f56269e1 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue12429.xaml @@ -0,0 +1,43 @@ + + + + +