Stealing focus

Topics: Getting Started
Jul 31, 2013 at 6:15 AM
I'm having some "fun" stealing the users focus when Showing/injecting windows.

I'm using WindowManager to launch a window as a popup. I use a conductor to inject various screens into this window.

If it's the first time I show the window and injuect it's fine as I set the window attribute ShowActivated = true and it works from anywhere, activated through the app or a hot key.

If the parent conductor view is open already and the activation is initiated while I have focus to one of the apps windows or the actual window stealing focus works correctly.

If the parent conductor view is open already and the activation is intiated while I have focus to say note pad using a hot key, everthing is displayed correctly but the focus is never stolen.

I've tried an extension on Window Manager, getting the view, finding the focus method on the view and calling it - it even returns true but the focus is never stolen if the view is already open and the focus is in another app i.e. notepad.

Any help appreciated here.
Aug 18, 2013 at 8:32 PM
Hey BronwenZ, I think I'm having the exact same problem. Showing my window never steals focus away. I described my problem more in detail on this StackOverflow post:

Have you found a way?
Aug 19, 2013 at 6:47 AM
Hey @mleroy - Haven't found a way yet. Let me know if you find a workable solution
Aug 19, 2013 at 2:01 PM
I ended up on this article:

It suggests to call view.Activate(). It works my demo code and I'll confirm on the SO post in some time that it fixed the intermittent issue on my actual app. Could you share whether or not it fixes the problem for you?
Aug 19, 2013 at 10:40 PM
Not for me. My case that doesn't work is when they re-open a view using something outside of the application i.e. using a hot key when they have focus set to a different application e.g. notepad.
Jan 5, 2014 at 4:42 PM
Edited Jan 5, 2014 at 4:44 PM
If you are looking for a service for setting Focus, I have a solution in Handling Focus with Caliburn Micro