![](/img/trans.png)
[英]Interface method has interface argument but want to use class argument in the implementation
[英]Interface implementation has an extra argument in the function
以下是ICommand成员的定义: http : //msdn.microsoft.com/en-us/library/system.windows.input.icommand.execute.aspx
签名是:
void Execute(
Object parameter
)
它由RoutedCommand实现,具有以下签名( http://msdn.microsoft.com/en-us/library/system.windows.input.routedcommand.execute.aspx ):
public void Execute(
Object parameter,
IInputElement target
)
RoutedCommand如何在成员函数中使用额外参数(IInputElement)实现ICommand?
它使用显式接口实现来“隐藏”采用单个参数的ICommand.Execute
方法。 采用两个参数的Execute
方法不是 ICommand.Execute
的实现。
public class RoutedCommand : ICommand
{
public void Execute(object parameter, IInputElement target)
{
// ...
}
// explicit interface implementation of ICommand.Execute
void ICommand.Execute(object parameter)
{
// ...
}
}
ICommand.Execute()接口方法是显式实现的。 文件在这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.