Keyboard.IsKeyToggled(Key) Metoda

Definicja

Określa, czy określony klucz jest przełączany.

public:
 static bool IsKeyToggled(System::Windows::Input::Key key);
public static bool IsKeyToggled (System.Windows.Input.Key key);
static member IsKeyToggled : System.Windows.Input.Key -> bool
Public Shared Function IsKeyToggled (key As Key) As Boolean

Parametry

key
Key

Określony klucz.

Zwraca

true jeśli key jest w stanie przełączonym; w przeciwnym razie wartość false.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą IsKeyToggled metody określić stan określonego klucza. Klucz Return jest przekazywany do IsKeyToggled metody . Jeśli metoda zwróci truewartość , zmieni się tło obiektu Button .

// Uses the Keyboard.IsToggled to determine if a key is toggled.
if (Keyboard.IsKeyToggled(Key.Return))
{
    btnIsToggle.Background = Brushes.Red;
}
else
{
    btnIsToggle.Background = Brushes.AliceBlue;
}
' Uses the Keyboard.IsToggled to determine if a key is toggled.
If Keyboard.IsKeyToggled(Key.Return) Then
    btnIsToggle.Background = Brushes.Red
Else
    btnIsToggle.Background = Brushes.AliceBlue
End If

Uwagi

Metoda GetKeyStates może służyć do określania zestawu stanów określonego klucza.

Dotyczy

Zobacz też