dotnet / dotnet/wpf

Unloaded event not called on Window when app closed

Open
#1,442 6 comments 2 reactions 0 assignees View on GitHub
.NET Framework
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 3.0.100-preview7-012821
* Windows version: Windows 10 16299
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

**Problem description:**

When window is closed with the close button in the title bar, the `Window.Unloaded` event is not called if this is the last open window of the application. This is inconsistent behavior as the event is normally called for other windows.

**Actual behavior:**

`Window.Unloaded` does not fire

**Expected behavior:**

`Window.Unloaded` should fire.

**Minimal repro:**

```
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Unloaded += Debug.WriteLine("Hit");
}
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.