Skip to content

Commit bead39d

Browse files
Update PropertyChanged.
1 parent 82d1b34 commit bead39d

8 files changed

Lines changed: 11 additions & 19 deletions

File tree

src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ override Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnH
1111
~override Microsoft.Maui.Controls.Handlers.Items.RecyclerViewScrollListener<TItemsView, TItemsViewSource>.OnScrollStateChanged(AndroidX.RecyclerView.Widget.RecyclerView recyclerView, int newState) -> void
1212
~override Microsoft.Maui.Controls.Handlers.Items.SelectableItemsViewAdapter<TItemsView, TItemsSource>.IsSelectionEnabled(Android.Views.ViewGroup parent, int viewType) -> bool
1313
override Microsoft.Maui.Controls.TitleBar.OnBindingContextChanged() -> void
14-
~override Microsoft.Maui.Controls.SwipeItems.OnPropertyChanged(string propertyName = null) -> void

src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ override Microsoft.Maui.Controls.Platform.Compatibility.ShellItemRenderer.ViewDi
1111
~override Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.DidMoveToParentViewController(UIKit.UIViewController parent) -> void
1212
override Microsoft.Maui.Controls.TitleBar.OnBindingContextChanged() -> void
1313
override Microsoft.Maui.Controls.Handlers.Items2.StructuredItemsViewController2<TItemsView>.UpdateFlowDirection() -> void
14-
~override Microsoft.Maui.Controls.SwipeItems.OnPropertyChanged(string propertyName = null) -> void

src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ override Microsoft.Maui.Controls.Platform.Compatibility.ShellItemRenderer.ViewDi
1111
~override Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.DidMoveToParentViewController(UIKit.UIViewController parent) -> void
1212
override Microsoft.Maui.Controls.TitleBar.OnBindingContextChanged() -> void
1313
override Microsoft.Maui.Controls.Handlers.Items2.StructuredItemsViewController2<TItemsView>.UpdateFlowDirection() -> void
14-
~override Microsoft.Maui.Controls.SwipeItems.OnPropertyChanged(string propertyName = null) -> void

src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
override Microsoft.Maui.Controls.Shapes.Shape.OnPropertyChanged(string? propertyName = null) -> void
33
override Microsoft.Maui.Controls.GraphicsView.OnBindingContextChanged() -> void
44
override Microsoft.Maui.Controls.TitleBar.OnBindingContextChanged() -> void
5-
~override Microsoft.Maui.Controls.SwipeItems.OnPropertyChanged(string propertyName = null) -> void

src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
override Microsoft.Maui.Controls.Shapes.Shape.OnPropertyChanged(string? propertyName = null) -> void
44
override Microsoft.Maui.Controls.GraphicsView.OnBindingContextChanged() -> void
55
override Microsoft.Maui.Controls.TitleBar.OnBindingContextChanged() -> void
6-
~override Microsoft.Maui.Controls.SwipeItems.OnPropertyChanged(string propertyName = null) -> void

src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
override Microsoft.Maui.Controls.Shapes.Shape.OnPropertyChanged(string? propertyName = null) -> void
33
override Microsoft.Maui.Controls.GraphicsView.OnBindingContextChanged() -> void
44
override Microsoft.Maui.Controls.TitleBar.OnBindingContextChanged() -> void
5-
~override Microsoft.Maui.Controls.SwipeItems.OnPropertyChanged(string propertyName = null) -> void

src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
override Microsoft.Maui.Controls.Shapes.Shape.OnPropertyChanged(string? propertyName = null) -> void
33
override Microsoft.Maui.Controls.GraphicsView.OnBindingContextChanged() -> void
44
override Microsoft.Maui.Controls.TitleBar.OnBindingContextChanged() -> void
5-
~override Microsoft.Maui.Controls.SwipeItems.OnPropertyChanged(string propertyName = null) -> void

src/Controls/src/Core/SwipeView/SwipeItems.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Collections.ObjectModel;
66
using System.Collections.Specialized;
7+
using System.ComponentModel;
78
using System.Linq;
89
using Microsoft.Extensions.Logging;
910

@@ -70,21 +71,19 @@ public SwipeItems(IEnumerable<ISwipeItem> swipeItems)
7071

7172
_swipeItems = new ObservableCollection<Maui.ISwipeItem>(swipeItems) ?? throw new ArgumentNullException(nameof(swipeItems));
7273
_swipeItems.CollectionChanged += OnSwipeItemsChanged;
74+
75+
// Self-subscribe to PropertyChanged so we can notify the owning SwipeView when
76+
// any of this SwipeItems' properties change. The handler's Target is this same
77+
// SwipeItems instance, so the subscription cannot keep the SwipeItems alive
78+
// beyond its natural lifetime, and it does not root the owning SwipeView
79+
// either (the SwipeView is located on demand via Element.Parent, which is a
80+
// WeakReference internally — see issue #35481).
81+
PropertyChanged += OnSelfPropertyChanged;
7382
}
7483

75-
// Override OnPropertyChanged so we can notify the owning SwipeView when Mode /
76-
// SwipeBehaviorOnInvoked change. The notification goes through Parent (a weak
77-
// reference managed by AddLogicalChild), so the owning SwipeView is never rooted
78-
// by this SwipeItems instance (issue #35481).
79-
protected override void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null)
84+
void OnSelfPropertyChanged(object sender, PropertyChangedEventArgs e)
8085
{
81-
base.OnPropertyChanged(propertyName);
82-
83-
if (propertyName == ModeProperty.PropertyName ||
84-
propertyName == SwipeBehaviorOnInvokedProperty.PropertyName)
85-
{
86-
NotifyOwner();
87-
}
86+
NotifyOwner();
8887
}
8988

9089
/// <summary>

0 commit comments

Comments
 (0)