KeyStates, énumération
.NET Framework 3.0
Specifies constants that define the state of a key.
Assembly : PresentationCore (dans presentationcore.dll)
Espace de noms XML : http://schemas.microsoft.com/winfx/2006/xaml/presentation
Cette énumération possède un attribut FlagsAttribute qui permet la combinaison d'opérations de bits de ses valeurs membres.
Espace de noms: System.Windows.InputAssembly : PresentationCore (dans presentationcore.dll)
Espace de noms XML : http://schemas.microsoft.com/winfx/2006/xaml/presentation
The following example changes the color of a Button if the KeyStates of the key passed in the KeyEventArgs is Down. The state of the key is determined by using a bitwise AND operation. The same technique can be used to determine whether a key has multiple states, such as being in the Toggled state and the Down state.
// A bitwise AND operation is used in the comparison. // e is an instance of KeyEventArgs. // btnDown is a Button. if ((e.KeyStates & KeyStates.Down) > 0) { btnDown.Background = Brushes.Red; }