按下/取消按下WPF按钮时的触发事件 [英] Fire event when WPF button was pressed/unpressed

查看:77
本文介绍了按下/取消按下WPF按钮时的触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在按下WPF按钮(通过鼠标,键盘,触摸屏等)时触发一些事件,而在未按下WPF按钮时触发事件.

I need to fire some event when WPF button is pressed (by mouse, keyboard, touchscreen, etc) and to fire event when WPF buttons is unpressed.

如何执行此操作?这应该很容易,但是我找不到如何做到的.

How to do this? It should be easy but I can't find how to do this.

推荐答案

您可以从Button派生并覆盖

You can derive from Button and override the OnIsPressedChanged method and fire a custom event there.

或者您可以绑定到ButtonBase.IsPressed 属性.

Or you can bind to the ButtonBase.IsPressed property.

这篇关于按下/取消按下WPF按钮时的触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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