I am building a WPF application and I am having some trouble with focusing a window.
Basically, the flow of the application is this:
- User starts the application, a "loginwindow" is shown.
- User presses the login button in the loginwindow and a browser is opened with Process.Start(urlToJwtWebPage).
- The returnurl to retrieve the JWT token is 127.0.0.1 and a HttpListener is started to fetch the token from the returnurl query.
So far so good, this works and the token is retrieved.
When this is done an application window is opened, which works. The problem is that I cant get it to have keyboard focus?
I can put it in front, but the browser still have keyboard focus.
I've tried:
Topmost = true;
Activate();
Topmost = false;
and this only puts the window on top, but not with keyboard focus.
I've also tried Correct way (in .NET) to switch the focus to another application this but same thing happened anyway.