winform中devexpress bindcommand无效的解决方法

正常绑定,编译运行无报错,但无法执行command

fluentAPI.BindCommand(commandButton, (x, p) => x.DoSomething(p), x => parameter);

解决方法:
检查command访问权限,在devexpress规范中,command必须为 public void
提示信息:All public void methods with zero or one parameter, declared in POCO ViewModels, are treated as commands.
在view层写绑定的时候,通过alt+enter自动生成的command是Internal修饰的(程序集访问权限),无法访问。

    internal  void DoSomething(int p) {//将  internal改为public
XtraMessageBox.Show(string.Format(
"Hello! The parameter passed to command is {0}." + Environment.NewLine +
"And I'm running, because the `canExecute` condition is `True` for this parameter." + Environment.NewLine +
"Try to change this parameter!", p));
}

原文:https://blog.csdn.net/weixin_43862847/article/details/86766417

上一篇:Devexpress xaf针对某个用户登录后在面板中设置导航无效的解决方法


下一篇:未能从程序集“System.ServiceModel, Version=3.0.0.0”中加载类型“System.ServiceModel.Activation.HttpModule” 的解决办法