Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 1.29 KB

keyboardaccelerator_invoked.md

File metadata and controls

40 lines (32 loc) · 1.29 KB
-api-id -api-type
E:Microsoft.UI.Xaml.Input.KeyboardAccelerator.Invoked
winrt event

Microsoft.UI.Xaml.Input.KeyboardAccelerator.Invoked

-description

Occurs when the key combination for this KeyboardAccelerator is pressed.

-remarks

Handle this event to override the default KeyboardAccelerator behavior.

-examples

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.

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;
    }
  }}

-see-also

KeyboardAcceleratorInvokedEventArgs, Keyboard accelerators