MouseButtonEventArgs.ButtonState Propiedad

Definición

Obtiene el estado del botón asociado al evento.Gets the state of the button associated with the event.

public:
 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

Valor de propiedad

MouseButtonState

Estado en el que se encuentra el botón.The state the button is in.

Ejemplos

En el ejemplo siguiente se crea un controlador de eventos de botón del mouse que cambia el color del objeto que controla el evento.The following example creates a mouse button event handler that changes the color of the object that handles the event. El color que se elige depende de si el botón del mouse se presionó o se liberó.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

Comentarios

La Mouse clase proporciona propiedades y métodos adicionales para determinar el estado del mouse.The Mouse class provides additional properties and methods for determining the state of the mouse.

Se aplica a

Consulte también