From 2c99fc19bc4ebb34089b4c9ac1cfb260969ec1c8 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 17 Apr 2023 17:13:45 +0200 Subject: [PATCH 01/13] Clear BindingContext when cell is queued for reuse This avoid holding references to objects that were already removed. --- .../src/Core/Handlers/Items/iOS/TemplatedCell.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs index 2b6e481198a0..78f15e820eff 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs @@ -115,6 +115,15 @@ protected void Layout(CGSize constraints) PlatformHandler.VirtualView.Arrange(rectangle); _size = rectangle.Size; } + + public override void PrepareForReuse() + { + if (PlatformHandler?.VirtualView is View view) + { + view.BindingContext = null; + } + base.PrepareForReuse(); + } public void Bind(DataTemplate template, object bindingContext, ItemsView itemsView) { From 6c035dbcb328675c32c6095741c135501084b235 Mon Sep 17 00:00:00 2001 From: GitHub Actions Autoformatter Date: Mon, 17 Apr 2023 15:21:46 +0000 Subject: [PATCH 02/13] Auto-format source code --- src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs index 78f15e820eff..cca42206d0d7 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs @@ -115,7 +115,7 @@ protected void Layout(CGSize constraints) PlatformHandler.VirtualView.Arrange(rectangle); _size = rectangle.Size; } - + public override void PrepareForReuse() { if (PlatformHandler?.VirtualView is View view) From dd3cea4a97a330ec6dc41ec75050714a866e6cd6 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 18 Apr 2023 16:23:18 +0200 Subject: [PATCH 03/13] Update src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt to list PrepareForReuse override. --- src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt index a489446f682e..06fe1bf82fc7 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -106,6 +106,7 @@ Microsoft.Maui.Controls.Region.Equals(Microsoft.Maui.Controls.Region other) -> b Microsoft.Maui.Controls.Shapes.Matrix.Equals(Microsoft.Maui.Controls.Shapes.Matrix other) -> bool Microsoft.Maui.Controls.Shapes.Shape.~Shape() -> void Microsoft.Maui.Controls.VisualElement.~VisualElement() -> void +override Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.PrepareForReuse() -> void override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillLayoutSubviews() -> void override Microsoft.Maui.Controls.LayoutOptions.GetHashCode() -> int override Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.TitleViewContainer.LayoutSubviews() -> void From a6f1de13a5a8cf25532e5311fae79074aa314a81 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 18 Apr 2023 16:33:01 +0200 Subject: [PATCH 04/13] Empty commit From 352d72cacd7d529dbf669b5d58789e5bfde3b7cf Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 19 Apr 2023 10:21:19 +0200 Subject: [PATCH 05/13] Apply code review feedback --- .../src/Core/Handlers/Items/iOS/TemplatedCell.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs index cca42206d0d7..0d51e7933d0a 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs @@ -120,6 +120,7 @@ public override void PrepareForReuse() { if (PlatformHandler?.VirtualView is View view) { + view.MeasureInvalidated -= MeasureInvalidated; view.BindingContext = null; } base.PrepareForReuse(); @@ -166,18 +167,10 @@ public void Bind(DataTemplate template, object bindingContext, ItemsView itemsVi // Same template if (oldElement != null) { - if (oldElement.BindingContext == null || !(oldElement.BindingContext.Equals(bindingContext))) - { - // If the data is different, update it - - // Unhook the MeasureInvalidated handler, otherwise it'll fire for every invalidation during the - // BindingContext change - oldElement.MeasureInvalidated -= MeasureInvalidated; - oldElement.BindingContext = bindingContext; - oldElement.MeasureInvalidated += MeasureInvalidated; + oldElement.BindingContext = bindingContext; + oldElement.MeasureInvalidated += MeasureInvalidated; - UpdateCellSize(); - } + UpdateCellSize(); } } From 3233079308998ff162312329050210a11f8410b2 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 20 Apr 2023 20:00:54 +0200 Subject: [PATCH 06/13] Update public API for maccatalyst --- .../src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 8a57f5667bfb..e6fc9c14d4eb 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -105,6 +105,7 @@ Microsoft.Maui.Controls.Region.Equals(Microsoft.Maui.Controls.Region other) -> b Microsoft.Maui.Controls.Shapes.Matrix.Equals(Microsoft.Maui.Controls.Shapes.Matrix other) -> bool Microsoft.Maui.Controls.Shapes.Shape.~Shape() -> void Microsoft.Maui.Controls.VisualElement.~VisualElement() -> void +override Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.PrepareForReuse() -> void override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillLayoutSubviews() -> void override Microsoft.Maui.Controls.LayoutOptions.GetHashCode() -> int override Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.TitleViewContainer.LayoutSubviews() -> void From 0338614d2cfc676b923dbd1fa43687eec0a0a38e Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 22 Apr 2023 15:05:36 +0200 Subject: [PATCH 07/13] Add test that shows the fix is not fully working yet --- .../CollectionView/CollectionViewTests.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs index 63829158bbe3..473a940d2ef7 100644 --- a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs @@ -397,5 +397,52 @@ static async Task WaitForUIUpdate(Rect frame, CollectionView collectionView, int timeout -= interval; } } + + [Fact] + public async Task ClearingItemsSourceClearsBindingContext() + { + SetupBuilder(); + + IReadOnlyList logicalChildren = null; + var collectionView = new CollectionView + { + ItemTemplate = new DataTemplate(() => new Label() { HeightRequest = 30, WidthRequest = 200 }), + WidthRequest = 200, + HeightRequest = 200, + }; + + await CreateHandlerAndAddToWindow(collectionView, async handler => + { + var data = new ObservableCollection() + { + new MyRecord("Item 1"), + new MyRecord("Item 2"), + new MyRecord("Item 3"), + }; + collectionView.ItemsSource = data; + await Task.Delay(100); + + logicalChildren = collectionView.LogicalChildrenInternal; + Assert.NotNull(logicalChildren); + Assert.True(logicalChildren.Count == 3); + + // Clear collection + data.Clear(); + + await Task.Delay(100); + }); + + await Task.Yield(); + + Assert.NotNull(logicalChildren); + Assert.True(logicalChildren.Count <= 3, "LogicalChildren should not grow in size!"); + + foreach (var logicalChild in logicalChildren) + { + Assert.Null(logicalChild.BindingContext); + } + } + + record MyRecord(string Name); } } From 89f4af76a3ccf16cb04bfb0164cdd46c64aec617 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 23 Apr 2023 14:58:04 +0200 Subject: [PATCH 08/13] [iOS] Unbind TemplatedCell when it goes out of display and the bound item is no longer present in items source. Extend the test to check rebinding after clearing the source. --- .../Handlers/Items/iOS/ItemsViewDelegator.cs | 20 ++++++++++++ .../Core/Handlers/Items/iOS/TemplatedCell.cs | 15 ++++++--- .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 1 + .../net-maccatalyst/PublicAPI.Unshipped.txt | 1 + .../CollectionView/CollectionViewTests.cs | 32 +++++++++++++------ 5 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs index a4888f30e420..61adbae08c50 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs @@ -108,6 +108,26 @@ public override nfloat GetMinimumLineSpacingForSection(UICollectionView collecti public override void CellDisplayingEnded(UICollectionView collectionView, UICollectionViewCell cell, NSIndexPath indexPath) { + if (cell is TemplatedCell templatedCell && + (templatedCell.PlatformHandler?.VirtualView as View)?.BindingContext is object bindingContext) + { + // We want to unbind a cell that is no longer present in the items source. Unfortunately + // it's too expensive to check directly, so let's check that the current binding context + // matches the item at a given position. + // + //var itemIndex = ViewController?.ItemsSource.GetIndexForItem(bindingContext); + //if (itemIndex.Item == -1) + // templatedCell.Unbind(); + + var itemsSource = ViewController?.ItemsSource; + if (itemsSource == null || + !itemsSource.IsIndexPathValid(indexPath) || + itemsSource[indexPath] != bindingContext) + { + templatedCell.Unbind(); + } + } + if (ItemsViewLayout.ScrollDirection == UICollectionViewScrollDirection.Horizontal) { var actualWidth = collectionView.ContentSize.Width - collectionView.Bounds.Size.Width; diff --git a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs index 0d51e7933d0a..c58a9c06c51d 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs @@ -58,6 +58,15 @@ protected void ClearConstraints() ConstrainedDimension = default; } + public void Unbind() + { + if (PlatformHandler?.VirtualView is View view) + { + view.MeasureInvalidated -= MeasureInvalidated; + view.BindingContext = null; + } + } + public override UICollectionViewLayoutAttributes PreferredLayoutAttributesFittingAttributes( UICollectionViewLayoutAttributes layoutAttributes) { @@ -118,11 +127,7 @@ protected void Layout(CGSize constraints) public override void PrepareForReuse() { - if (PlatformHandler?.VirtualView is View view) - { - view.MeasureInvalidated -= MeasureInvalidated; - view.BindingContext = null; - } + Unbind(); base.PrepareForReuse(); } diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 06fe1bf82fc7..fd3388ad5881 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -88,6 +88,7 @@ virtual Microsoft.Maui.Controls.DragStartingEventArgs.GetPosition(Microsoft.Maui virtual Microsoft.Maui.Controls.DropEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point? *REMOVED*override Microsoft.Maui.Controls.RefreshView.MeasureOverride(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size Microsoft.Maui.Controls.Border.~Border() -> void +Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.Unbind() -> void Microsoft.Maui.Controls.IWindowCreator Microsoft.Maui.Controls.IWindowCreator.CreateWindow(Microsoft.Maui.Controls.Application! app, Microsoft.Maui.IActivationState? activationState) -> Microsoft.Maui.Controls.Window! Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.FlyoutOverlapsDetailsInPopoverMode.get -> bool diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index e6fc9c14d4eb..133cf7bbaf7f 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -87,6 +87,7 @@ virtual Microsoft.Maui.Controls.DragStartingEventArgs.GetPosition(Microsoft.Maui virtual Microsoft.Maui.Controls.DropEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point? *REMOVED*override Microsoft.Maui.Controls.RefreshView.MeasureOverride(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size Microsoft.Maui.Controls.Border.~Border() -> void +Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.Unbind() -> void Microsoft.Maui.Controls.IWindowCreator Microsoft.Maui.Controls.IWindowCreator.CreateWindow(Microsoft.Maui.Controls.Application! app, Microsoft.Maui.IActivationState? activationState) -> Microsoft.Maui.Controls.Window! Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.FlyoutOverlapsDetailsInPopoverMode.get -> bool diff --git a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs index 473a940d2ef7..435a3ec6c5c2 100644 --- a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs @@ -427,20 +427,32 @@ await CreateHandlerAndAddToWindow(collectionView, async h Assert.True(logicalChildren.Count == 3); // Clear collection + var savedItems = data.ToArray(); data.Clear(); - await Task.Delay(100); - }); - - await Task.Yield(); + // Check that all logical children have no binding context + foreach (var logicalChild in logicalChildren) + { + Assert.Null(logicalChild.BindingContext); + } - Assert.NotNull(logicalChildren); - Assert.True(logicalChildren.Count <= 3, "LogicalChildren should not grow in size!"); + // Re-add the old children + foreach (var savedItem in savedItems) + { + data.Add(savedItem); + } - foreach (var logicalChild in logicalChildren) - { - Assert.Null(logicalChild.BindingContext); - } + // Check that the right number of logical children have binding context again + int boundChildren = 0; + foreach (var logicalChild in logicalChildren) + { + if (logicalChild.BindingContext is not null) + { + boundChildren++; + } + } + Assert.Equal(3, boundChildren); + }); } record MyRecord(string Name); From 26ea17d88a5f88110c90fa2b6f7133804ef37b9a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 24 Apr 2023 10:33:07 +0200 Subject: [PATCH 09/13] Relax the test to make it pass on Android. --- .../Elements/CollectionView/CollectionViewTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs index 435a3ec6c5c2..73046ecaad4c 100644 --- a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs @@ -430,6 +430,8 @@ await CreateHandlerAndAddToWindow(collectionView, async h var savedItems = data.ToArray(); data.Clear(); + await Task.Delay(100); + // Check that all logical children have no binding context foreach (var logicalChild in logicalChildren) { @@ -442,6 +444,8 @@ await CreateHandlerAndAddToWindow(collectionView, async h data.Add(savedItem); } + await Task.Delay(100); + // Check that the right number of logical children have binding context again int boundChildren = 0; foreach (var logicalChild in logicalChildren) From a08071877309b9cda69424c5bc50e76926f28538 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 24 Apr 2023 12:44:19 +0200 Subject: [PATCH 10/13] Update src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs Co-authored-by: Rui Marinho --- .../src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs index 61adbae08c50..bc9116e27edd 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs @@ -120,9 +120,9 @@ public override void CellDisplayingEnded(UICollectionView collectionView, UIColl // templatedCell.Unbind(); var itemsSource = ViewController?.ItemsSource; - if (itemsSource == null || + if (itemsSource is null || !itemsSource.IsIndexPathValid(indexPath) || - itemsSource[indexPath] != bindingContext) + itemsSource[indexPath] is not bindingContext) { templatedCell.Unbind(); } From 84def917870c5884ea5fb2f41736ba38433be8d1 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 24 Apr 2023 12:47:00 +0200 Subject: [PATCH 11/13] Use Equals to compare item list elements --- src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs index bc9116e27edd..1fc3de4c3734 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs @@ -122,7 +122,7 @@ public override void CellDisplayingEnded(UICollectionView collectionView, UIColl var itemsSource = ViewController?.ItemsSource; if (itemsSource is null || !itemsSource.IsIndexPathValid(indexPath) || - itemsSource[indexPath] is not bindingContext) + !Equals(itemsSource[indexPath], bindingContext)) { templatedCell.Unbind(); } From 8e97a93841b9bcfc48bda228441026e9e62e16a7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Autoformatter Date: Tue, 9 May 2023 10:56:57 +0000 Subject: [PATCH 12/13] Auto-format source code --- .../DeviceTests/Elements/CollectionView/CollectionViewTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs index 73046ecaad4c..1789a67ae26d 100644 --- a/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.cs @@ -406,7 +406,7 @@ public async Task ClearingItemsSourceClearsBindingContext() IReadOnlyList logicalChildren = null; var collectionView = new CollectionView { - ItemTemplate = new DataTemplate(() => new Label() { HeightRequest = 30, WidthRequest = 200 }), + ItemTemplate = new DataTemplate(() => new Label() { HeightRequest = 30, WidthRequest = 200 }), WidthRequest = 200, HeightRequest = 200, }; From 83ec31d562c01505b9ec68e02ef1e8d3d5e56012 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 21 Sep 2023 05:56:04 +0200 Subject: [PATCH 13/13] PR feedback --- .../src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs | 4 ---- src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs | 2 +- .../src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 1 - .../Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | 1 - 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs index 1fc3de4c3734..3716b1b87dd8 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs @@ -114,10 +114,6 @@ public override void CellDisplayingEnded(UICollectionView collectionView, UIColl // We want to unbind a cell that is no longer present in the items source. Unfortunately // it's too expensive to check directly, so let's check that the current binding context // matches the item at a given position. - // - //var itemIndex = ViewController?.ItemsSource.GetIndexForItem(bindingContext); - //if (itemIndex.Item == -1) - // templatedCell.Unbind(); var itemsSource = ViewController?.ItemsSource; if (itemsSource is null || diff --git a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs index c58a9c06c51d..f4945af4ed26 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs @@ -58,7 +58,7 @@ protected void ClearConstraints() ConstrainedDimension = default; } - public void Unbind() + internal void Unbind() { if (PlatformHandler?.VirtualView is View view) { diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt index fd3388ad5881..06fe1bf82fc7 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -88,7 +88,6 @@ virtual Microsoft.Maui.Controls.DragStartingEventArgs.GetPosition(Microsoft.Maui virtual Microsoft.Maui.Controls.DropEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point? *REMOVED*override Microsoft.Maui.Controls.RefreshView.MeasureOverride(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size Microsoft.Maui.Controls.Border.~Border() -> void -Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.Unbind() -> void Microsoft.Maui.Controls.IWindowCreator Microsoft.Maui.Controls.IWindowCreator.CreateWindow(Microsoft.Maui.Controls.Application! app, Microsoft.Maui.IActivationState? activationState) -> Microsoft.Maui.Controls.Window! Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.FlyoutOverlapsDetailsInPopoverMode.get -> bool diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 133cf7bbaf7f..e6fc9c14d4eb 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -87,7 +87,6 @@ virtual Microsoft.Maui.Controls.DragStartingEventArgs.GetPosition(Microsoft.Maui virtual Microsoft.Maui.Controls.DropEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point? *REMOVED*override Microsoft.Maui.Controls.RefreshView.MeasureOverride(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size Microsoft.Maui.Controls.Border.~Border() -> void -Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.Unbind() -> void Microsoft.Maui.Controls.IWindowCreator Microsoft.Maui.Controls.IWindowCreator.CreateWindow(Microsoft.Maui.Controls.Application! app, Microsoft.Maui.IActivationState? activationState) -> Microsoft.Maui.Controls.Window! Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.FlyoutOverlapsDetailsInPopoverMode.get -> bool