CanExecuteRoutedEventArgs.CanExecute 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
명령 대상에서 이 이벤트와 연결된 이벤트를 실행할 수 있는지 여부를 RoutedCommand 나타내는 값을 가져오거나 설정합니다.
public:
property bool CanExecute { bool get(); void set(bool value); };
public bool CanExecute { get; set; }
member this.CanExecute : bool with get, set
Public Property CanExecute As Boolean
속성 값
true명령 대상에서 이벤트를 실행할 수 있으면 이고, 그렇지 않으면 . false 기본값은 false입니다.
예제
다음은 명령 대상이 컨트롤인 CanExecuteRoutedEventHandler 경우에만 true를 반환하는 예제입니다.
Source 먼저 이벤트 데이터가 .로 Control캐스팅됩니다. 이 값이
// CanExecuteRoutedEventHandler that only returns true if
// the source is a control.
private void CanExecuteCustomCommand(object sender,
CanExecuteRoutedEventArgs e)
{
Control target = e.Source as Control;
if(target != null)
{
e.CanExecute = true;
}
else
{
e.CanExecute = false;
}
}
' CanExecuteRoutedEventHandler that only returns true if
' the source is a control.
Private Sub CanExecuteCustomCommand(ByVal sender As Object, ByVal e As CanExecuteRoutedEventArgs)
Dim target As Control = TryCast(e.Source, Control)
If target IsNot Nothing Then
e.CanExecute = True
Else
e.CanExecute = False
End If
End Sub
설명
와 같은 MenuItemButton많은 명령 원본은 있는 CanExecute 경우 false 비활성화되고 있는 경우 CanExecute 사용하도록 설정됩니다true.