MouseButton Enumeration
.NET Framework 3.0
Defines values that specify the buttons on the mouse.
Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
The following example creates a MouseDown event handler that uses the MouseButton enumeration to determine which button was pressed. Depending on which button was pressed, the background of the control that fired the event is changed.
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; } } }
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: