MVVM路由和中继命令 [英] MVVM Routed and Relay Command

查看:388
本文介绍了MVVM路由和中继命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RoutedCommand 之间的区别是什么? a>和 RelayCommand
何时使用RoutedCommand和何时在MVVM模式中使用RelayCommand?

What is the Difference between the RoutedCommand and RelayCommand ? When to use RoutedCommand and when to use RelayCommand in MVVM pattern ?

推荐答案

RoutedCommand 是WPF的一部分,而 RelayCommand 由WPF专家Josh Smith创建)。

RoutedCommand is part of WPF, while RelayCommand was created by a WPF Disciple, Josh Smith ;).

但是,严格地说,RS Conley描述了一些差异。关键的区别是RoutedCommand是一个ICommand实现,它使用一个RoutedEvent来路由树,直到找到命令的CommandBinding,而RelayCommand没有路由,直接执行一些委托。在M-V-VM场景中,RelayCommand(Prism中的DelegateCommand)可能是更好的选择。

Seriously, though, RS Conley described some of the differences. The key difference is that RoutedCommand is an ICommand implementation that uses a RoutedEvent to route through the tree until a CommandBinding for the command is found, while RelayCommand does no routing and instead directly executes some delegate. In a M-V-VM scenario a RelayCommand (DelegateCommand in Prism) is probably the better choice all around.

这篇关于MVVM路由和中继命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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