MouseButtonEventArgs.ChangedButton MouseButtonEventArgs.ChangedButton MouseButtonEventArgs.ChangedButton MouseButtonEventArgs.ChangedButton Property

Definición

Obtiene el botón asociado al evento.Gets the button associated with the event.

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

Valor de propiedad

Botón que se ha presionado.The button which was pressed.

Ejemplos

El ejemplo siguiente crea un controlador de eventos de botón del mouse que cambia el color de un objeto según el botón del mouse que se ha presionado.The following example creates a mouse button event handler that changes the color of an object depending on the mouse button which was pressed. El ChangedButton se comprueba la propiedad para determinar qué botón se presionó.The ChangedButton property is checked to determine which button was pressed.

private void MouseButtonDownHandler(object sender, MouseButtonEventArgs e)
{
    Control src = e.Source as Control;

    if (src != null)
    {
        switch (e.ChangedButton)
        {
            case MouseButton.Left:
                src.Background = Brushes.Green;
                break;
            case MouseButton.Middle:
                src.Background = Brushes.Red;
                break;
            case MouseButton.Right:
                src.Background = Brushes.Yellow;
                break;
            case MouseButton.XButton1:
                src.Background = Brushes.Brown;
                break;
            case MouseButton.XButton2:
                src.Background = Brushes.Purple;
                break;
            default:
                break;
        }
    }
}
Private Sub MouseButtonDownHandler(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    Dim src As Control = TryCast(e.Source, Control)

    If src IsNot Nothing Then
        Select Case e.ChangedButton
            Case MouseButton.Left
                src.Background = Brushes.Green
            Case MouseButton.Middle
                src.Background = Brushes.Red
            Case MouseButton.Right
                src.Background = Brushes.Yellow
            Case MouseButton.XButton1
                src.Background = Brushes.Brown
            Case MouseButton.XButton2
                src.Background = Brushes.Purple
            Case Else
        End Select
    End If
End Sub

Comentarios

La Mouse clase proporciona métodos y propiedades 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: