WPF App loses focus completely on window close

What most likely happened here is you have two independent top level windows and closed one of them. This will sometimes cause focus to jump to another application.

This also happens if one windows owns a second, which in turn owns a third. Probable BUG in the Win32 API but its been with us forever so good luck getting it fixed.

The workaround is to manually hand focus back to child in the Closing event of the grandchild. But in this case, grandchild is a messagebox so you can’t do that. The easiest thing to do is to own messagebox to parent. The next easiest is to make your own messagebox control.

Leave a Comment