CommandBinding.CanExecute CommandBinding.CanExecute CommandBinding.CanExecute CommandBinding.CanExecute Event

정의

명령 대상에서 이 CommandBinding에 연결된 명령을 실행할 수 있는지 여부를 결정하는 검사를 시작하면 발생합니다.Occurs when the command associated with this CommandBinding initiates a check to determine whether the command can be executed on the command target.

public:
 event System::Windows::Input::CanExecuteRoutedEventHandler ^ CanExecute;
public event System.Windows.Input.CanExecuteRoutedEventHandler CanExecute;
member this.CanExecute : System.Windows.Input.CanExecuteRoutedEventHandler 
Public Event CanExecute As CanExecuteRoutedEventHandler 

예제

다음 예제에서는 CommandBinding 매핑되는 ExecutedRoutedEventHandlerCanExecuteRoutedEventArgs 처리기를 Open 명령 합니다.The following example creates a CommandBinding that maps an ExecutedRoutedEventHandler and a CanExecuteRoutedEventArgs handler to the Open command.

<Window.CommandBindings>
  <CommandBinding Command="ApplicationCommands.Open"
                  Executed="OpenCmdExecuted"
                  CanExecute="OpenCmdCanExecute"/>
</Window.CommandBindings>
// Creating CommandBinding and attaching an Executed and CanExecute handler
CommandBinding OpenCmdBinding = new CommandBinding(
    ApplicationCommands.Open,
    OpenCmdExecuted,
    OpenCmdCanExecute);

this.CommandBindings.Add(OpenCmdBinding);
' Creating CommandBinding and attaching an Executed and CanExecute handler
Dim OpenCmdBinding As New CommandBinding(ApplicationCommands.Open, AddressOf OpenCmdExecuted, AddressOf OpenCmdCanExecute)

Me.CommandBindings.Add(OpenCmdBinding)

다음은 CanExecuteRoutedEventHandler 집합 CanExecutetrue입니다.The following shows the CanExecuteRoutedEventHandler which sets CanExecute to true.

void OpenCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
    e.CanExecute = true;
}
Private Sub OpenCmdCanExecute(ByVal sender As Object, ByVal e As CanExecuteRoutedEventArgs)
    e.CanExecute = True
End Sub

설명

경우는 CanExecute 메서드를를 RoutedCommand 호출 되는 PreviewCanExecute 명령 대상에서 이벤트가 발생 합니다.When the CanExecute method on a RoutedCommand is called, the PreviewCanExecute event is raised on the command target. 이벤트 처리 되지 않은 경우는 CanExecute 이벤트가 발생 합니다.If the event is not handled, the CanExecute event is raised. 명령 대상에는 CommandBinding 명령에 대 한는 CanExecute 처리기에 대 한 CommandBinding 라고 합니다.If the command target has a CommandBinding for the command, the CanExecute handler for that CommandBinding is called. 명령 대상에 없는 경우는 CommandBinding 명령에 대를 CanExecute 있는 요소를 검색 하는 요소 트리를 이벤트 버블링을 CommandBinding 명령과 사용 하 여 연결 합니다.If the command target does not have a CommandBinding for the command, the CanExecute event bubbles up the element tree searching for an element that has a CommandBinding associated with the command.

라우팅 이벤트 정보Routed Event Information

식별자 필드Identifier field CanExecuteEvent
라우팅 전략Routing strategy 버블링Bubbling
대리자Delegate CanExecuteRoutedEventHandler

적용 대상

추가 정보