繁体   English   中英

WPF中的弹出键绑定

[英]Popup keybinding in wpf

是否可以绑定在wpf弹出窗口中按下的键?

我这样尝试,但似乎没有效果:

<Popup.InputBindings>
   <KeyBinding Key="Escape" Command="Close" />
   <KeyBinding Key="Enter" Command="{Binding NewDateSelectedCommand}" />
</Popup.InputBindings>

您可以,必须将Focus()设置为弹出窗口

<Popup x:Name="popup">
    <Popup.InputBindings>
       <KeyBinding Key="Escape" Command="Close" />
       <KeyBinding Key="Enter" Command="{Binding NewDateSelectedCommand}" />
    </Popup.InputBindings>
</Popup>

public void ShowPopup()
{
    this.popup.IsOpen = true;
    this.popup.Focus();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM