Vic
Vic

Reputation: 129

WP7 back key press handling in child popup

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 inside 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)...

Upvotes: 2

Views: 2535

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500055

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.

Upvotes: 4

Related Questions