I wrote a small control that creates a popup for my Win8 Phone application which does all the nasty things for me like rotation, proper placement etc. The popup is opened in a Popup control but not on a new phone page. To close the popup, my control hooks up to the "backKeyPressed" event of the underlying page. This works like charm until the underlying page has its own implementation of BackKeyPressed event. In this case, the page event is triggered but not the popup control event.
If I would own the event, I could create my own stack to call the last added event first, but I do not own the event of the pages. As far as I know, I am unable to unregister any previously attached event handler and reassign it once my control unsubscribes from the event.
I could have only one implementation for the BackKeyPressed event which then informs the popup control to close itself (if open), if nothing was open, do the Page specific implementation. But this would require code changes on all pages where I might want to use the popup. Even worse, if I have 5 possible popups, I would have to check all of them :-( So I am looking for an option to handle this centrally.
What other options do I have to overcome this situation?