an enter key are handled twice in WPF/Winform mixed project
Posted
by
user527403
on Stack Overflow
See other posts from Stack Overflow
or by user527403
Published on 2011-01-06T20:51:31Z
Indexed on
2011/01/06
20:54 UTC
Read the original article
Hit count: 434
I have a winform dashboard which hosts some WPF dialogs. When I select a row in the winform ListView and hit Enter key, OnItemActivate is called which launches a WPF dialog. However, the WPF dialog appears and then disappears immediately because the default button “cancel” is hit. It seems that the Enter key is triggered twice, one for launching the WPF dialog, the other for hitting cancel button. We don’t want the WPF dialog to be canceled by the Enter key hitting.
According to the stack trace, it looks like that WPF and Winform handle the enter key separately. The WPF does not know that the enter key has been handled by the Winform ListView. Is this by design in Winform and WPF interop?
To make the enter key not close the WPF dialog, we have to change the focus from the cancel button to another control (e.g. a textblock). Is there a better way to fix/around this issue?
© Stack Overflow or respective owner