Skip to content

Improvements to WPF-UI.Tray NotifyIconService Functionality #1668

@KIM-SEO-TAE

Description

@KIM-SEO-TAE

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions