I made a usercontrol that contains a togglebutton. When the user clicks on it, it shows a fullscreen-sized popup. I want to add the following functionality: when the user presses the hardware back button and the popup is opened, close the popup. The problem is that only the parent page of the usercontrol has backkeypress event. How can I handle this in开发者_如何学运维side the usercontrol which is a reusable control? I try to avoid handling backbutton press in the page's code, so handling this like calling a method of the usercontrol from the page's OnBackKeyPress eventhandler is the last thing I'd like to do (the page is programmatically generated)...
The control will need to find a reference to the page somehow - either in the constructor, or by walking up the UI tree until it finds a PhoneApplicationPage
. It can then subscribe to the event itself, and unsubscribe from the event when it's closed.
精彩评论