Nick
Nick

Reputation: 2265

WPF Window Activate Not Capturing Focus

I have a legacy C++ application and a WPF application that communicate via sockets. The legacy application launches a WPF window by sending data over the socket that the WPF application handles. The application creates a Window and calls the Activate method on it. Topmost is set to true on the window and back to false like so to bring the window to the front.

window.Topmost = true; window.Activate(); window.Topmost = false;

The problem is that sometimes focus remains in the parent C++ window although the WPF window is activated and on top. When Activate() returns true, focus is in the WPF window. When Activate() returns false, focus is in the C++ window. Does anyone have any ideas on how to move focus to the WPF window every time?

Thanks,

Nick

Upvotes: 4

Views: 1595

Answers (1)

Jeronymite
Jeronymite

Reputation: 51

Set Focus to any control in the WPF window. This should make the window the focused window.

Upvotes: 0

Related Questions