How to handle the back button on Windows Phone 7

后端 未结 3 509
时光取名叫无心
时光取名叫无心 2020-12-01 01:04

On the windows phone 7 emulator, when the hardware back button is pressed, the default behaviour is for it to close your current application. I want to override this defaul

3条回答
  •  感情败类
    2020-12-01 01:52

    If you don't want the default back key behavior, set Cancel = true in the CancelEventArgs parameter in OnBackKeyPress. In my page, I've overridden the back button to close a web browser control instead of navigating back.

        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            if (Browser.Visibility == Visibility.Visible)
            {
                Browser.Visibility = Visibility.Collapsed;
                e.Cancel = true;
            }
        }
    

提交回复
热议问题