【发布时间】:2011-12-03 06:02:24
【问题描述】:
可能重复:
How can I assign the 'Close on Escape-key press' behavior to all WPF windows within a project?
当用户单击退出按钮时,我想关闭我的 wpf 项目中的窗口。我不想在每个窗口中都编写代码,但想创建一个可以在用户按下转义键时捕获的类。
【问题讨论】:
-
这不是我的解决方案。我什至不希望
在每个窗口中都完成。我想用 Style 写它,但那不起作用,因为 属性在 Style 中不可用 -
查看 [this][1] 帖子 - 它准确解释了如何实现此目标 [1]:stackoverflow.com/questions/3863431/…