Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
WindowsFormsHost and unpinned panes
posted

I have a fly out pane and a tabbed UI that displays documents with WinForms controls (using a WindowsFormsHost).

The problem is that if the pane is unpinned, when I click on the WinForms control, and then go back to the pane, the pane doesn't get keyboard focus even if I click on it (mouse events, OTOH, will be handled). It looks and behaves as if it wasn't activated (except for the mouse).

If the pane is pinned, the problem doesn't appear.

The problem also doesn't appear when I click on any other WPF focusable control after the WinForms control gets the focus.

A workaround for this is to call Focus on the WindowsFormsHost (for instance, in the WinForms control's GotFocus handler, or in MouseEnter/MouseLeave handlers).