1
我有一個定義了InputBindings中的鍵綁定的窗口。他們第一次工作,當我把重點放在窗體上的任何控件上。顯示消息框後沒有工作的快捷鍵
但是,當顯示消息框並按下「確定」時,他們的快捷鍵不起作用,直到我將焦點設置在窗口中的控件上。
我化InputBindings:
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+N" Command="{x:Static local:MainWindow.NewMenuCommand}" />
<KeyBinding Gesture="Ctrl+O" Command="{x:Static local:MainWindow.OpenMenuCommand}" />
<KeyBinding Gesture="Ctrl+S" Command="{x:Static local:MainWindow.SaveMenuCommand}" />
<KeyBinding Gesture="Ctrl+Q" Command="{x:Static local:MainWindow.CloseMenuCommand}" />
</Window.InputBindings>
我化CommandBindings:
<Window.CommandBindings>
<CommandBinding Command="{x:Static local:MainWindow.NewMenuCommand}" Executed="NewEntity" />
<CommandBinding Command="{x:Static local:MainWindow.OpenMenuCommand}" Executed="OpenEntity" />
<CommandBinding Command="{x:Static local:MainWindow.SaveMenuCommand}" Executed="SaveEntity" />
<CommandBinding Command="{x:Static local:MainWindow.CloseMenuCommand}" Executed="CloseEntity" />
</Window.CommandBindings>
它必須處理沒有定義消息框的父/所有者。通過使用 MessageBox.Show(我,「保存」) 在代替: MSGBOX(「保存」) 製造它解決這個問題 – 2011-04-29 15:06:17
好吧,其實在我的情況我已經實現了我的自定義消息框設置父母/孩子關係也不適合我。這就是爲什麼我使用上述方法.. – 2011-04-30 06:41:48