如何修复“编译器错误 - 无法从方法组转换为 System.Delegate"? [英] How do I fix 'compiler error - cannot convert from method group to System.Delegate'?

查看:13
本文介绍了如何修复“编译器错误 - 无法从方法组转换为 System.Delegate"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 public MainWindow()
 {
    CommandManager.AddExecutedHandler(this, ExecuteHandler);
 }

 void ExecuteHandler(object sender, ExecutedRoutedEventArgs e)
 {
 }

错误 1 ​​参数 2:无法从方法组"转换为System.Delegate"

Error 1 Argument 2: cannot convert from 'method group' to 'System.Delegate'

推荐答案

我猜有多个不同签名的 ExecuteHandler.只需将您的处理程序转换为您想要的版本:

I guess there are multiple ExecuteHandler with different signatures. Just cast your handler to the version you want to have:

CommandManager.AddExecuteHandler(this, (Action<object,ExecutedRoutedEventArgs>)ExecuteHandler);

这篇关于如何修复“编译器错误 - 无法从方法组转换为 System.Delegate"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆