WP8 双击返回键退出

        bool isExit = false;

        // 构造函数
        public MainPage()
        {
            InitializeComponent();
            isExit = false;
            // 用于本地化 ApplicationBar 的示例代码
            //BuildLocalizedApplicationBar();
        }

        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            if (!isExit)
            {
                isExit = true;
                var toast = new ToastPrompt {Message = "再按一次退出程序"};
                toast.Completed += (o, ex) => { isExit = false; };
                toast.Show();
                e.Cancel = true;
            }
            else
            {
                NavigationService.RemoveBackEntry();
            }
        }

需要引用Coding4Fun.Toolkit.Controls:https://coding4fun.codeplex.com/

你可能感兴趣的:(退出)