绑定命令窗口标题栏的X按钮 [英] Bind command to X-button of window title bar

查看:242
本文介绍了绑定命令窗口标题栏的X按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WPF维护窗口有一个按钮退出工具栏;一个CommandExit被绑定此按钮。该CommandExit退出之前进行一些检查。

My WPF maintenance window have a toolbar with a button "Exit"; a CommandExit is bind with this button. The CommandExit perform some checks before exit.

现在,如果我点击关闭窗口(标题栏的X按钮)的按钮,这个检查将被忽略。

Now, if I click to close button of the window (x-button of title bar), this checks are ignored.

如何才能做到绑定CommandExit到窗口的X按钮?

How can I do to bind CommandExit to window x-button?

推荐答案

您必须实现你的主窗口的事件关闭的事件处理程序,在那里你可以做检查,并取消关闭动作。这是做的最简单的方法,但是,否则你不得不重新设计整个窗口和主题。

You have to implement event handler of your main window's event "Closing" where you can do checks and cancel the closing action. This is easiest way to do it, however otherwise you have to redesign whole window and its theme.

这篇关于绑定命令窗口标题栏的X按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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