MessageBox.Show in App Closing/Deactivated events

后端 未结 2 535
鱼传尺愫
鱼传尺愫 2021-01-29 04:16

I have a MessageBox being shown in Application Closing/Deactivated methods in Windows Phone 7/8 application. It is used to warn the user for active timer being disabled because

2条回答
  •  盖世英雄少女心
    2021-01-29 04:53

    Register BackKeyPress event on RootFrame.

    RootFrame.BackKeyPress += BackKeyPressed;
    private void BackKeyPressed(object sender, CancelEventArgs e)
        {
            var result = (MessageBox.Show("Do you want to exit XXXXX?", "Application Closing", MessageBoxButton.OKCancel));
            if (result == MessageBoxResult.Cancel)
            {
                // Cancel default navigation
                e.Cancel = true;
            }
    }
    

提交回复
热议问题