Windows Phone Back KeyPress + MessageBox crashes the app without Selection

前端 未结 3 886
攒了一身酷
攒了一身酷 2021-01-15 06:19

I have a strange issue overriding BackkeyPress Function in code behind, inside the function i have a simple message box to Go back or cancel navigation ( stay in current pag

3条回答
  •  暖寄归人
    2021-01-15 06:42

    http://msdn.microsoft.com/en-US/library/windowsphone/develop/jj206947(v=vs.105).aspx

    In Windows Phone 8, if you call Show in OnBackKeyPress(CancelEventArgs) or a handler for the BackKeyPress event, the app will exit.

    You can work around this by calling Show on a different thread, as described in the following steps. Override BackKeyPress or create a handler for the BackKeyPress event. Set the Cancel to true to cancel the back key press action. Dispatch a method that shows the MessageBox. If the user chooses to leave the app, call Terminate(), otherwise, do nothing.

提交回复
热议问题