Windows Form user control hosted in WPF - How to capture the leave event?
Posted
by OKB
on Stack Overflow
See other posts from Stack Overflow
or by OKB
Published on 2010-05-06T12:30:54Z
Indexed on
2010/05/11
7:54 UTC
Read the original article
Hit count: 344
Hi,
In my WPF application I'm hosting a custom Windows Form User Control together with other wpf controls. My custom user control is hosted in wpf using a WindowsFormsHost control. This custom user control contains (the parent so to speak) other custom win form controls (children controls). The children controls can be single or composite controls.
How can I capture the leave event on a child control when the user navigates from the last child user control in the parent custom user control to a wpf user control?
According to MSDN (http://msdn.microsoft.com/en-us/library/ms751797.aspx) the leave event is not supported in following scenarios:
Enter and Leave events are not raised when the following focus changes occur:
1. From inside to outside a WindowsFormsHost control.
2. From outside to inside a WindowsFormsHost control.
3. Outside a WindowsFormsHost control.
4. From a Windows Forms control hosted in a WindowsFormsHost control to an ElementHost control hosted inside the same WindowsFormsHost.
Scenario 1 and 2 is exactly what I struggle with. Do you have any solution to this problem? Some workaround or anything is appreciated:)
Best Regards,
OKB
© Stack Overflow or respective owner