-
-
Notifications
You must be signed in to change notification settings - Fork 941
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe
The NotifyIconService allows activating a NotifyIcon independently without requiring a XAML file.
Currently, the method used to automate the disposal of InternalNotifyIconManager is to register a parent window so that InternalNotifyIconManager is disposed when the window’s Closing event occurs.
However, users often rely on the Window.Closing event to determine whether the window should actually be closed, and they may decide to either proceed or cancel the operation.
Therefore, if NotifyIconService intends to dispose InternalNotifyIconManager through the parent window, it seems more appropriate to use the Closed event rather than Closing.
Describe the solution you'd like
Wpf.Ui.Tray(4.2.0.0)
Wpf.Ui.Tray.NotifyIconService
AS-IS
public void SetParentWindow(Window parentWindow)
{
if (ParentWindow is not null)
{
ParentWindow.Closing -= OnParentWindowClosing;
}
ParentWindow = parentWindow;
ParentWindow.Closing += OnParentWindowClosing;
}
private void OnParentWindowClosing(object? sender, CancelEventArgs e)
{
internalNotifyIconManager.Dispose();
}
TO-BE
public void SetParentWindow(Window parentWindow)
{
if (ParentWindow is not null)
{
ParentWindow.Closed -= OnParentWindowClosed;
}
ParentWindow = parentWindow;
ParentWindow.Closed += OnParentWindowClosed;
}
private void OnParentWindowClosed(object? sender, EventArgs e)
{
internalNotifyIconManager.Dispose();
}
Describe alternatives you've considered
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request