我想在用户按下键盘上的ESC时隐藏Popup.
在UWP应用程序中,请考虑使用CoreWindow.CharacterReceived事件
在UserControl中,在Constructor方法中添加事件处理程序:
public CustomPopupControl() { this.InitializeComponent(); Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived; } private void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args) { if(args.KeyCode==27) //ESC { //Do somthing this.Visibility = Visibility.Collapsed; } }