独自の DelegateCommand を実装する場合は、次のコードに示すように、パラメーターなしのアクションを受け取るコンストラクターを使用できます。
public DelegateCommand(Action<object> execute, Func<object, bool> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute", "execute cannot be null");
if (canExecute == null)
throw new ArgumentNullException("canExecute", "canExecute cannot be null");
_execute = execute;
_canExecute = canExecute;
}
public DelegateCommand(Action<object> execute)
: this(execute, (o) => true)
{
}
public DelegateCommand(Action execute)
: this((o) => execute())
{
}
その最後のコンストラクターのオーバーロードでできること
var someCommand = new DelegateCommand(SomeMethod);
ここで、メソッドはパラメーターなしです