internal static void Cancel(InputDevice device, UIElement element = null) { switch (device) { case InputDevice.Keyboard: KeyboardHelper.Escape(element); break; case InputDevice.Gamepad: KeyboardHelper.GamepadB(element); break; default: throw new Exception("Invalid input device."); } }