-
Notifications
You must be signed in to change notification settings - Fork 138
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The behavior shares the same underlying animation retention issue as the Toast problem (#869).
However, WindowNotificationManager has an additional leak caused by the property binding. When creating a NotificationCard, the PositionProperty is bound to the manager. Since WindowNotificationManager is a long-lived object, it maintains active subscriptions to every card created, preventing the Garbage Collector from reclaiming them.
Replacing the indexer binding with an explicit Bind and calling Dispose() when the message closes correctly breaks this connection.
var notificationControl = new NotificationCard
{
Content = content,
NotificationType = type,
ShowIcon = showIcon,
ShowClose = showClose,
// REMOVED: [!NotificationCard.PositionProperty] = this[!PositionProperty]
};
// Store the subscription to dispose of it later
var bindingSubscription = notificationControl.Bind(
NotificationCard.PositionProperty,
this.GetObservable(PositionProperty));
// Add style classes if any
if (classes is not null)
{
foreach (var @class in classes)
{
notificationControl.Classes.Add(@class);
}
}
notificationControl.MessageClosed += (sender, _) =>
{
onClose?.Invoke();
// Explicitly unsubscribe to allow GC to collect the control
bindingSubscription.Dispose();
_items?.Remove(sender);
};Reactions are currently unavailable
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't working