How does one close a Popup in Silverlight 3 by pressing the Escape key?

Posted by Jacob on Stack Overflow See other posts from Stack Overflow or by Jacob
Published on 2010-03-27T00:21:47Z Indexed on 2010/03/27 0:23 UTC
Read the original article Hit count: 1256

I've just implemented a context menu control in Silverlight 3. One feature lacking in this control is for the Esc key to dismiss the menu. I've tried adding a KeyUp event handler in a few places, but the handler is never called. It looks like KeyUp is only available for items that can have focus. The popup menu cannot have focus, however, as it is only an ItemsControl.

Have any of you successfully implemented having the Esc key close a Popup, or do you have any other suggestions on how I can implement this behavior?

© Stack Overflow or respective owner

Related posts about silverlight-3.0

Related posts about popup