我具有用于分配命令的以下代码:
private ICommand aButtonClickedCommand;
public ICommand AButtonClickedCommand =>
aButtonClickedCommand ??
(aButtonClickedCommand = new Command(ProcessButtonClickedCommand));
private void ProcessButtonClickedCommand()
{
App.DB.IncrementPoints(Settings.cfs, phrasesFrame.phrase, 1, 2);
Change.points = true;
phrasesFrame.CancelTimer2();
}
当我想添加一些参数时,我将其更改为:
public ICommand AButtonClickedCommand =>
aButtonClickedCommand ??
(aButtonClickedCommand = new Command(ButtonClickedCommand((int)Settings.aBtn, 1)));
private void ButtonClickedCommand(int pts, int col)
{
App.DB.IncrementPoints(Settings.cfs, phrasesFrame.phrase, pts, col);
Change.points = true;
phrasesFrame.CancelTimer2();
}
但是我收到一条错误消息:
错误CS1503:参数1:无法从“无效”转换为“ System.Action”(CS1503)
答案 0 :(得分:1)
您可以为命令使用委托
public ICommand AButtonClickedCommand =>
aButtonClickedCommand ??
(aButtonClickedCommand = new Command(() => ButtonClickedCommand((int)Settings.aBtn, 1)));