我不知道Josh Smith和Laurent Bugnion的RelayCommand实现是否有区别,但是在我看过的任何地方,听起来像是RelayCommand的执行部分可以取0或1个参数。我只能够得到它用0到工作时,我尝试类似:无法将单个参数传递给MVVM Light Toolkit的RelayCommand中的lambda函数
public class Test
{
public RelayCommand MyCommand { get; set; }
public Test()
{
MyCommand = new RelayCommand((param) => SomeFunc(param));
}
private void SomeFunc(object param)
{
}
}
我得到的错误:Delegate 'System.Action' does not take '1' arguments
。为了确保我没有疯狂,我去了RelayCommand的定义,以确保我的解决方案中没有一些流氓实现,但是果然,这只是Action,而不是Action <>。
我到底在想什么?
可能重复[CanExecute on RelayCommand not working](http://stackoverflow.com/questions/2306063/canexecute-on-relaycommandt-not-working) –
2010-06-07 04:07:03