MouseButtonEventArgs.ButtonState Proprietà
Definizione
Ottiene lo stato del pulsante associato all'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
Valore della proprietà
Stato del pulsante.The state the button is in.
Esempi
Nell'esempio seguente viene creato un gestore dell'evento del pulsante del mouse che modifica il colore dell'oggetto che gestisce l'evento.The following example creates a mouse button event handler that changes the color of the object that handles the event. Il colore scelto varia a seconda che il pulsante del mouse sia stato premuto o rilasciato.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
Commenti
La Mouse classe fornisce proprietà e metodi aggiuntivi per determinare lo stato del mouse.The Mouse class provides additional properties and methods for determining the state of the mouse.