dotnet / dotnet/wpf

Missing LostKeyboardFocus event in Windows 11

Open
#6,246 3 comments 1 reaction 0 assignees View on GitHub
Investigate Needs minimal repro project
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Missing-LostKeyboardFocus-event-in-Windo/1678933)._

---
When the MainWindow's LostKeyboardFocus event is triggered in my WPF (bridge) app, i.e. when the user clicks the mouse outside my app, the MainWindow will be hidden with Hide() in the LostKeyboardFocus handler. If the user clicks the app icon in the taskbar another time, the new app instance sends a message to the already existing MainWindow, whereupon it shows itself again with Show(). The new app instance will then be closed.

Unfortunately, under Windows 11, when the MainWindow is displayed again, the LostKeyboardFocus event is no longer triggered if the user clicks outside the MainWindow. However, under Windows 8.1 and under Windows 10, the LostKeyboardFocus event is triggered. Under Windows 11, only when the user clicks inside the app and then outside the app, the LostKeyboardFocus event is triggered and the MainWindow can be hidden again.

I asked in the developer forum, but there the problem could not be reproduced. [https://docs.microsoft.com/en-us/answers/questions/746213/missing-lostkeyboardfocus-event-in-windows-11.html] ()

Sample project: [https://1drv.ms/u/s!AnJkahC5qjfigQTcZXXX36fj8ah9]()

---
### Original Comments

#### Feedback Bot on 2/28/2022, 10:46 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

---
### Original Solutions
(no solutions)

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.