KeyboardAccelerator.Invoked Event
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.
Occurs when the key combination for this KeyboardAccelerator is pressed.
// Register
event_token Invoked(TypedEventHandler<KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs const&> const& handler) const;
// Revoke with event_token
void Invoked(event_token const* cookie) const;
// Revoke with event_revoker
KeyboardAccelerator::Invoked_revoker Invoked(auto_revoke_t, TypedEventHandler<KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs const&> const& handler) const;
C#
public event TypedEventHandler<KeyboardAccelerator,KeyboardAcceleratorInvokedEventArgs> Invoked;
function onInvoked(eventArgs) { /* Your code */ }
keyboardAccelerator.addEventListener("invoked", onInvoked);
keyboardAccelerator.removeEventListener("invoked", onInvoked);
- or -
keyboardAccelerator.oninvoked = onInvoked;
Public Custom Event Invoked As TypedEventHandler(Of KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs)
This example shows how to override the "Select all" command (Ctrl+A keyboard accelerator) in a custom ListView control. We also set the Handled property to true to stop the event bubbling further.
C#
public class MyListView : ListView
{
…
protected override void OnKeyboardAcceleratorInvoked(KeyboardAcceleratorInvokedEventArgs args)
{
if(args.KeyboardAccelerator.Key == VirtualKey.A
&& args.KeyboardAccelerator.Modifiers == VirtualKeyModifiers.Control)
{
CustomSelectAll(TypeOfSelection.OnlyNumbers);
args.Handled = true;
}
}
…
}
Handle this event to override the default KeyboardAccelerator behavior.
Product | Versions |
---|---|
WinRT | Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |