ICommand 인터페이스

정의

명령을 정의합니다.

public interface class ICommand
public interface ICommand
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public interface ICommand
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public interface ICommand
type ICommand = interface
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
type ICommand = interface
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
type ICommand = interface
Public Interface ICommand
파생
특성

설명

RoutedCommandRoutedUICommand 는 Windows Presentation Foundation(WPF)의 ICommand 인터페이스 구현 두 가지입니다.

Windows 런타임 앱의 ICommand

인터페이스는 ICommand Windows 런타임 앱용 .NET으로 작성된 명령에 대한 코드 계약입니다. 이러한 명령은 Windows 런타임 XAMLButton, 특히 와 같은 UI 요소에 대한 명령 동작을 AppBarButton제공합니다. Windows 런타임 앱에 대한 명령을 정의하는 경우 기본적으로 .NET 앱에 대한 명령을 정의하는 데 사용하는 것과 동일한 기술을 사용합니다. 메서드를 구현하고 특히 구현하는 클래스를 ICommand 정의하여 명령을 구현합니다 Execute .

Windows 런타임 XAML은 을 지원하지 x:Static않으므로 Windows 런타임 XAML에서 명령을 사용하는 경우 태그 확장을 사용하지 x:Static 마세요. 또한 Windows 런타임 미리 정의된 명령 라이브러리가 없으므로 여기에 표시된 XAML 구문은 인터페이스를 구현하고 Windows 런타임 사용에 대한 명령을 정의하는 경우 실제로 적용되지 않습니다.

XAML 특성 사용

<object-property="predefined-command-name"/>
-or-
<object-property="predefined-class-name.predefined-command-name"/>
-or-
<object-property="{custom-class-name.custom-command-name}"/>

XAML 값

predefined-class-name
미리 정의된 명령 클래스 중 하나입니다.

predefined-command-name
미리 정의된 명령 중 하나입니다.

custom-class-name
사용자 지정 명령을 포함하는 사용자 지정 클래스입니다. 사용자 지정 클래스에는 일반적으로 접두사 매핑이 xlmns 필요합니다. 자세한 내용은 XAML 네임 스페이스 및 WPF XAML에 대 한 매핑 Namespace합니다.

custom-command-name
사용자 지정 명령입니다.

메서드

CanExecute(Object)

명령이 현재 상태에서 실행할 수 있는지 여부를 결정합니다.

Execute(Object)

명령이 호출될 때 호출될 메서드를 정의합니다.

이벤트

CanExecuteChanged

명령 실행 여부에 영향을 주는 변경 내용이 발생할 때 발생합니다.

적용 대상