DelegateCommand或RelayCommand [英] DelegateCommand or RelayCommand

查看:122
本文介绍了DelegateCommand或RelayCommand的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在WPF应用程序中实现M-V-VM模式.就设计ViewModel类而言,我想知道何时使用 DelegateCommand 以及何时使用 RelayCommand 通过Command公开内联操作.

还是100%可互换?有没有哪个场景比其他场景更受青睐?

谢谢

Hi,

I m implementing M-V-VM pattern in my WPF application. As far as designing ViewModel class is concerned I wanted to know when to use DelegateCommand and when to use RelayCommand to expose inline operations through Command.

or are they 100% interchangable? Is there any scenatrio where one is preferred over other?

Thanks

推荐答案

您不是第一个对此感到疑惑的人.对此进行了一些讨论,得出的基本结论是RelayCommand更轻巧,并且根据您的需求选择最适合给定点的那个.请查看这些链接以获取更多信息.

http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=63174 [ ^ ]

http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=63174 [ ^ ]

http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2 -aka-acb/ [ ^ ]

祝你好运!
You are not the first one wondering about this. There is some discussion going on about this with the basic conclusion that RelayCommand is more lightweight and based on your needs you choose the one that is best suited at a given point. Have a look at these links for more info.

http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=63174[^]

http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=63174[^]

http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/[^]

Good luck!


这里是MSDN上的详尽文章
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx [ ^ ]

这可能也很有趣:
DelegateCommand与RoutedCommand与EventHandler
[ ^ ]

问候
Espen Harlinn
Here is a thorough article from MSDN
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx[^]

This may also be of interest:
DelegateCommand vs RoutedCommand vs EventHandler
[^]

Regards
Espen Harlinn


这篇关于DelegateCommand或RelayCommand的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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