将命令绑定到事件? [英] Binding Commands to Events?

查看:35
本文介绍了将命令绑定到事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将命令绑定到事件的好方法是什么?在我的 WPF 应用程序中,我想通过我的 ViewModel 捕获和处理一些事件,但我不确定如何.诸如失去焦点、鼠标悬停、鼠标移动等之类的事情.由于我试图坚持 MVVM 模式,我想知道是否有纯 XAML 解决方案.

What's a good method to bind Commands to Events? In my WPF app, there are events that I'd like to capture and process by my ViewModel but I'm not sure how. Things like losing focus, mouseover, mousemove, etc. Since I'm trying to adhere to the MVVM pattern, I'm wondering if there's a pure XAML solution.

谢谢!

推荐答案

看看 Marlon Grech 的 附加命令行为,它可能正是您要找的

Have a look at Marlon Grech's Attached Command Behaviour, it could be exactly what you're looking for

这篇关于将命令绑定到事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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