簡體   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