-api-id | -api-type |
---|---|
E:Microsoft.UI.Xaml.Input.KeyboardAccelerator.Invoked |
winrt event |
Occurs when the key combination for this KeyboardAccelerator is pressed.
Handle this event to override the default KeyboardAccelerator behavior.
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;
}
}
…
}