Cette page vous a-t-elle été utile ?
Votre avis sur ce contenu est important. N'hésitez pas à nous faire part de vos commentaires.
Vous avez d'autres commentaires ?
1500 caractères restants
Exporter (0) Imprimer
Développer tout
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

UIElement.KeyUp Event

Occurs when a keyboard key is released while the UIElement has focus.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

Public Event KeyUp As KeyEventHandler
<uiElement KeyUp="eventhandler"/>

Use a handler based on KeyEventHandler to handle this event. To determine the specific key that was pressed, check Key or PlatformKeyCode. To determine if any modifier keys are pressed, check Keyboard.Modifiers.

The KeyUp event is a bubbling event. This means that if multiple KeyUp event handlers are registered for a sequence of objects connected by parent-child relationships in the object tree, the event is received by each object in that relationship. The bubbling metaphor indicates that the event starts at the object that has focus while the key is pressed and works its way up the object tree. For a bubbling event, the sender available to the event handler identifies the object where the event is handled, not necessarily the object that actually received the input condition that initiated the event. To get the object that initiated the event, use the OriginalSource value of the event's RoutedEventArgs event data.

Element focus and the ability to initiate a keyboard event are tied. In order to generate the KeyUp event, the UIElement must have focus.

On the TextBox class, there is a TextChanged event that has potential interactions with KeyUp. For details, see TextBox.

KeyUp and OnKeyUp

Controls that inherit KeyUp can provide handling for the event that acts as handler for all instances, by overriding the OnKeyUp method. This might include marking the Handled value of the event as true, which has the effect of suppressing further handling of the KeyUp event for some or all keys on any instance of the control (and potentially any subclass of the control). For more information, see OnKeyUp.

You can also register handlers such that they are invoked even for already-handled routed events. For more information, see AddHandler.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Microsoft réalise une enquête en ligne pour recueillir votre opinion sur le site Web de MSDN. Si vous choisissez d’y participer, cette enquête en ligne vous sera présentée lorsque vous quitterez le site Web de MSDN.

Si vous souhaitez y participer,
© 2015 Microsoft