在MVVM应用程序的视图中订阅Usercontrol事件 [英] Subscribing Usercontrol events withn the view of MVVM application

查看:118
本文介绍了在MVVM应用程序的视图中订阅Usercontrol事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要在MVVM项目的视图中使用Usercontrol。

Usercontrol不是用MVVM编写的体系结构。

无法用MVVM样式重写用户控件。

在MVVM项目中,我需要订阅从用户控件触发的事件。

怎么可能?



请提供一个例子的解决方案。



问候,

Hashim

Hi,

I need to use a Usercontrol in a view of an MVVM project.
The Usercontrol is not written with MVVM architecture.
The user control could not be re written in MVVM style.
In MVVM project, I need to subscribe an event fired from the user control.
How is it possible?

Kindly provide a solution with an example.

Regards,
Hashim

推荐答案

解决方案位于

System.Windows.Interactivity命名空间。



它允许您在事件触发时使用命令。



详细说明可在此处找到:

http://blog.magnusmontin .net / 2013/06/30 / handling-events-in-an-mvvm-wpf-application / [ ^ ]



只需查看EventTriggers。
The solution lies in the
System.Windows.Interactivity namespace.

It allows you to use commands when triggered by events.

A detailled explanation can be found here:
http://blog.magnusmontin.net/2013/06/30/handling-events-in-an-mvvm-wpf-application/[^]

Just look for "EventTriggers".


这篇关于在MVVM应用程序的视图中订阅Usercontrol事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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