WPF 应用程序最小到系统托盘
此内容年代久远,谨慎参考
先建立一个 RoutedUICommand
,x:key
为 CommandDefualtButton
,然后响应 Ctrl+D 的 KeyBinding,用 CommandBindingCanExecute
来判断是否满足 CommandBinding 的执行条件,如果满足就执行 CommandBindingExecuted
xml<Window>
<Window.Resources>
<RoutedUICommand x:Key="CommandDefualtButton" Text="CommandDefualtButton_C"/>
</Window.Resources>
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+D" Command="{StaticResource ResourceKey=CommandDefualtButton}"/>
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource ResourceKey=CommandDefualtButton}" CanExecute="CommandBindingCanExecute" Executed="CommandBindingExecuted"/>
</Window.CommandBindings>
</Window>