本文介绍了如何禁用 Ctrl+1 的默认 RichTextBox 命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Snoop 显示命令是ApplySingleSpace",但是当我尝试通过 这篇文章.像这样:
Snoop shows that the command is "ApplySingleSpace", but when I try disabling it via the method described in this article . Like this:
<RichTextBox.CommandBindings>
<CommandBinding
Command="ApplySingleSpace"
CanExecute="BlockTheCommand"/>
</RichTextBox.CommandBindings>
.
private void BlockTheCommand(object sender,
CanExecuteRoutedEventArgs e)
{
e.CanExecute = false;
e.Handled = true;
}
我的应用程序崩溃,因为没有 ApplySingleSpace
命令.ApplySingleSpace
也不在 EditingCommands
中.
My app crashes because there is no ApplySingleSpace
command. ApplySingleSpace
is not in the EditingCommands
either.
我错过了什么?
推荐答案
如何使用自定义命令覆盖 KeyBinding 来执行您想要的操作,而不是尝试以某种方式禁用它?
How about overwriting that KeyBinding with a custom command that does what you want instead of trying to somehow disable it?
<RichTextBox.InputBindings>
<KeyBinding Command="local:YourCommands.Cmd1" Gesture="CTRL+1" />
<RichTextBox.InputBindings>
摘自这个问题.
这篇关于如何禁用 Ctrl+1 的默认 RichTextBox 命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!