返回键的使用

本文参考自:这篇博文这里

有的时候堆栈返回键搞不清楚咋回事,但是想让用户,点了返回键后,按照他们的习惯去做,就得重写返回键了,

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)

{

    //你自己的代码。认真负责些。

    e.Cancel = true; //取消默认行为。

}

 退出程序:

protected override void OnBackKeyPress(CancelEventArgs e)
        {
            Application.Current.Terminate();//这是winphone8特有的一个方法。
            e.Cancel = true;
            OnBackKeyPress(e);//当按下硬件"返回"按钮时调用,将e.Cancel设置为true时,已指示请求由应用程序处理(即:系统硬件已经不起作用),这句完全可以注释掉。
         }

  

posted on 2014-06-19 15:28  鸣动我心  阅读(336)  评论(0)    收藏  举报