MouseButtonEventArgs.ButtonState 속성


이벤트와 연결된 단추의 상태를 가져옵니다.Gets the state of the button associated with the event.

 property System::Windows::Input::MouseButtonState ButtonState { System::Windows::Input::MouseButtonState get(); };
public System.Windows.Input.MouseButtonState ButtonState { get; }
member this.ButtonState : System.Windows.Input.MouseButtonState
Public ReadOnly Property ButtonState As MouseButtonState

속성 값


단추의 상태입니다.The state the button is in.


다음 예제에서는 이벤트를 처리 하는 개체의 색을 변경 하는 마우스 단추 이벤트 처리기를 만듭니다.The following example creates a mouse button event handler that changes the color of the object that handles the event. 선택한 색 마우스 단추를 누르거나 놓을 여부에 따라 달라 집니다.The color that is chosen depends on whether the mouse button was pressed or released.

private void MouseButtonEventHandler(object sender, MouseButtonEventArgs e)
    if (e.ButtonState == MouseButtonState.Pressed)
        this.Background = Brushes.BurlyWood;

    if (e.ButtonState == MouseButtonState.Released)
        this.Background = Brushes.Ivory;
Private Sub MouseButtonEventHandler(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    If e.ButtonState = MouseButtonState.Pressed Then
        Me.Background = Brushes.BurlyWood
    End If

    If e.ButtonState = MouseButtonState.Released Then
        Me.Background = Brushes.Ivory
    End If
End Sub


Mouse 클래스는 추가 속성 및 마우스의 상태를 확인 하기 위한 메서드를 제공 합니다.The Mouse class provides additional properties and methods for determining the state of the mouse.

적용 대상

추가 정보