dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.1k stars 1.17k forks source link

Missing LostKeyboardFocus event in Windows 11 #6246

Open vsfeedback opened 2 years ago

vsfeedback commented 2 years ago

This issue has been moved from a ticket on Developer Community.


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)

gurpreet-wpf commented 2 years ago

We are not able to open sample project. Please attach the correct link.

MichaeIDietrich commented 2 years ago

For some reason the link behind seems to be broken and is different to the shown text. But you can copy the text manually and paste it into the browser's address bar. It'll redirects to a OneDrive storage.

lindexi commented 2 years ago

@gurpreet-wpf

Please attach the correct link.

MissingLostKeyboardFocus.zip