//设置一个DispatcherTimer,控制三秒内再次点击返回键时执行退出逻辑
public void ExitBy2Click(System.ComponentModel.CancelEventArgs e)
{
if (!IsExit)
{
IsExit = true;
e.Cancel = true;
_timer = new DispatcherTimer();
_timer.Start();
SystemTrayMessage.Instance.StartAdv("再按一次退出", 3, false);
_timer.Interval = TimeSpan.FromSeconds(3);
_timer.Tick += (sender, ee) =>
{
IsExit = false;
e.Cancel = false;
_timer.Stop();
};
return;
}
else
{
while (NavigationService.BackStack.Any())
NavigationService.RemoveBackEntry();
base.OnBackKeyPress(new CancelEventArgs());
// App.Current.Terminate();
//new Microsoft.Xna.Framework.Game().Exit();//wp7
}