绑定命令的CanExecute方法中传递的参数是绑定控件中指定的CommandParameter吗?如果不是,它从哪里来的?
CommandParameter
会被发送到 CanExecute
和 Execute(d)
事件中。Alex Curtis是正确的:
public bool CanExecute(object parameter)
public void Execute(object parameter)
使用作为命令的CommandParameter
设置的对象。
当调用ICommand的OnCanExecuteChanged(EventArgs e)
时,这也是需要知道的,因为该方法不允许传递任何参数。因此,CanExecute必须使用先前设置的CommandParameter。
CommandParameter
。 - Rachel