首先在Resources中建立Command的名稱, 這部份用來連結CommandBindings和InputBindings
<Window.Resources> <RoutedUICommand x:Key="OpenFile" Text="Open File"/> </Window.Resources>接下來設定CommandBindings
其中CommandBinding_Executed是執行的Function名稱
<Window.CommandBindings> <CommandBinding Command="{StaticResource OpenFile}" Executed="CommandBinding_Executed"/> </Window.CommandBindings>最後設定InputBindings
<Window.InputBindings> <KeyBinding Key="O" Modifiers="Ctrl" Command="{StaticResource OpenFile}"/> </Window.InputBindings>