MouseButtonEventArgs.ButtonState Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
The state the button is in.
Examples
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
Remarks
The Mouse class provides additional properties and methods for determining the state of the mouse.
Applies to
See also
Feedback
https://aka.ms/ContentUserFeedback.
Binnenkort: Gedurende 2024 worden GitHub Issues uitgefaseerd als het feedbackmechanisme voor inhoud. Dit wordt vervangen door een nieuw feedbacksysteem. Ga voor meer informatie naar:Feedback verzenden en bekijken voor