[MvvM Light]RelayCommand

RelayCommand  : ICommand类

A command whose sole purpose is to relay its functionality to other

objects by invoking delegates. The default return value for the CanExecute

method is 'true'.  This class does not allow you to accept command parameters in the

Execute and CanExecute callback methods.

ScreenClip(1)

用来转发命令。

构造函数中需要传入 Execute方法和CanExecute方法。

在RelayCommand中定义相应的字段为

readonly Action _execute;

readonly Func<Bool> _canExecute;

由于继承自ICommand 所以需实现接口:

bool CanExecute(object parameter)

event EventHandler CanExecuteChanged

void Execute(object parameter)

posted @ 2011-08-12 09:01  孤狼晖  阅读(763)  评论(0编辑  收藏  举报