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

 

posted on   jack_Meng  阅读(419)  评论(0编辑  收藏  举报

编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
历史上的今天:
2018-03-21 win7上搭建Android环境及调试
2017-03-21 提高开发水平的方法

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

支付宝打赏

主题色彩