开发者

WPF command binding: CanExecute parameter

Is the parameter passed to the CanExecute method of bound commands the CommandParameter specified in the binding control? If not, wher开发者_Go百科e does it come from?


The CommandParameter is sent to both the CanExecute and Execute(d) events.


Alex Curtis is right:

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

Use both the object that was set as CommandParameter for the command.

This is also good to know when calling ICommand's OnCanExecuteChanged(EventArgs e) because this method won't let you pass any parameter. So CanExecute must use the CommandParameter previously set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜