是否可以绑定在wpf弹出窗口中按下的键?
我这样尝试,但似乎没有效果:
<Popup.InputBindings>
<KeyBinding Key="Escape" Command="Close" />
<KeyBinding Key="Enter" Command="{Binding NewDateSelectedCommand}" />
</Popup.InputBindings>
答案 0 :(得分:0)
您可以,必须将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();
}