WPF命令绑定:CanExecute参数

8
绑定命令的CanExecute方法中传递的参数是绑定控件中指定的CommandParameter吗?如果不是,它从哪里来的?

是的,它就是 CommandParameter - Rachel
2个回答

11
CommandParameter 会被发送到 CanExecuteExecute(d) 事件中。

2

Alex Curtis是正确的:

public bool CanExecute(object parameter)
public void Execute(object parameter)

使用作为命令的CommandParameter设置的对象。

当调用ICommand的OnCanExecuteChanged(EventArgs e)时,这也是需要知道的,因为该方法不允许传递任何参数。因此,CanExecute必须使用先前设置的CommandParameter。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接