如果他/她点击后退按钮,如何警告用户? [英] How to warn a user if he/she taps the back button?

查看:69
本文介绍了如果他/她点击后退按钮,如何警告用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望用户询问用户是否应该在他/她点击后退按钮时存储应用数据。

I want the to ask the user if the app data should be stored when he/she tapps on the back button.

当用户做出他/她的选择时应用程序应处于暂停状态。

When the user made his/her choice the app should go in suspension state.

我是否可以实现这一目标?

How can I accomplish that?

推荐答案

protected override void OnBackKeyPress(CancelEventArgs e) { if(MessageBox.Show("Do you want to save data?","Exit?", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { //save data code goes here }

else {

//关闭应用

//close app

}
}

} }


甚至使用它在您的应用启动时首先打开的页面中的t

use this event in the page which opens first when your app launches


这篇关于如果他/她点击后退按钮,如何警告用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆