2010-02-07 9 views
0

다음 코드는 컴파일러에서 CanExecute 메서드의 반환 형식을 결정할 수 없기 때문에 컴파일되지 않습니다. 누군가 잘못 된 것에 관해 나를 도울 수 있습니까?ICommand _canExecute problem

class ViewCommand : ICommand 
    { 
     #region ICommand Members 

     public delegate Predicate<object> _canExecute(object param); 
     private ICommand _Execute; 

     _canExecute exe; 

     public bool CanExecute(object parameter) 
     { 
      return exe == null ? true : exe(parameter); // <-- Error no implicit conversion between Predicate<object> and bool 
     } 

... // more code 
} 

답변

1

ICommand의 인터페이스 파라미터를 취해 BOOL를 반환하는 함수로 CanExecute을 선언한다.

당신의 _canExecute는 매개 변수를 사용하고 내가 그 비록 의도였다 의심 exe

exe(parameter)(parameter); 

의 반환 값으로 매개 변수를 전달하는 것입니다 호출 할 Predicate<object>

방법을 반환합니다.

프레디 티브로 exe을 선언하고 위임자 선언을 건너 뛰고 싶다고 생각합니다.

private Predicate<object> exe; 

이 난 당신처럼 할 생각입니다 : 무엇이 잘못 될 수 ... 여전히 반환 형식에 만족하지

class ViewCommand : ICommand 
    { 
     #region ICommand Members 

     private ICommand _Execute; 

     Predicate<object> exe; 

     public bool CanExecute(object parameter) 
     { 
      return exe == null ? true : exe(parameter); // <-- Error no implicit conversion between Predicate<object> and bool 
     } 

... // more code 
} 
+0

지금, 당신의 마지막을했다,하지만? –

+0

_canExecute에 할당 할 조건부 정의는 무엇입니까? –

+0

개인 술어 _canExecute (object param); –