0
我在ContentControl
內有UserControl
。當我按下Escape
鍵時,我想讓用戶控制關閉。所以我用一個KeyBinding
這樣的:KeyBindings WPF未在負載上開火
<UserControl.CommandBindings>
<CommandBinding Command="{StaticResource CloseCommand}" Executed="Close" />
</UserControl.CommandBindings>
和
<UserControl.InputBindings>
<KeyBinding Key="Escape" Command="{StaticResource CloseCommand}" />
</UserControl.InputBindings>
當按下鍵Escape
,這個代碼應該火CloseCommand
。但是,第一次加載UserControl時,它不會觸發。如果我使用另一個UserControl導航並更改ContentControl
內容,那麼它可以工作。
有什麼想法是怎麼回事?
真的!非常感謝! – Sonhja
不客氣! –