WPF Richtextbox 和键盘快捷键

发布于 2024-09-14 05:43:59 字数 682 浏览 8 评论 0原文

我正在为德国用户实现一个带有 Richtextbox 的 WPF 应用程序。他们想要使用“普通”键盘快捷键来执行一些基本格式设置:粗体、斜体、下划线。

在英语中,快捷键 CTRL+BCTRL+ICTRL +U 正在 Richtextbox 中工作。

然而,“正常”的德语快捷键是 CTRL+SHIFT+F (Fett = Bold)、CTRL+< kbd>SHIFT+K(Kursiv = 斜体)和 CTRL+SHIFT+U(对于强调)。在德语 Windows 计算机 (Windows 7) 上运行 WPF (.net 4.0) 应用程序时,Richttextbox 对这些快捷方式没有反应,并且“英语”快捷方式也不起作用。只有 CTRL+SHIFT+F 正在做某事,但它是错误的:它使所选文本变为斜体,而不是粗体。

关于如何解决这个问题有什么建议吗?有没有办法为 RichTextBox 显式定义快捷方式映射?还有其他建议吗?这是一个错误吗?

亲切的问候,

罗比·德·萨特

I'm implementing a WPF application with a richtextbox for German users. They want to use their "normal" keyboard shortcuts to do some basic formatting: bold, italic, underline.

In English, the shortcuts CTRL+B, CTRL+I, and CTRL+U are working in the Richtextbox.

However the "normal" German shortcuts are CTRL+SHIFT+F (Fett = Bold), CTRL+SHIFT+K (Kursiv = Italic) and CTRL+SHIFT+U (for Underline). When running the WPF (.net 4.0) application on a German Windows machine (Windows 7), the Richttextbox is not reacting to these shortcuts and also the "English" shortcuts are not working. Only CTRL+SHIFT+F is doing something, but does it wrong: it makes the selected text Italic, not Bold.

Any suggestions on how to fix this? Is there a way to define the shortcut mappings explicitly for the RichTextBox? Any other suggestions? Is this a bug?

Kind regards,

Robbie De Sutter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2024-09-21 05:43:59

我认为您可以禁用您不想允许的命令绑定:

    <RichTextBox.CommandBindings>
     <CommandBinding 
       Command="EditingCommands.ToggleBold" 
       CanExecute="BlockTheCommand"/>
   </RichTextBox.CommandBindings>

    protected void BlockTheCommand(object sender,
         CanExecuteRoutedEventArgs e)
    {
         e.CanExecute = false;
         e.Handled = true;
    }

然后您可以使用如下所示的内容为您想要允许的内容创建自定义命令绑定: http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings-and-custom-commands

I think you can disable command binding you don't want to allow with:

    <RichTextBox.CommandBindings>
     <CommandBinding 
       Command="EditingCommands.ToggleBold" 
       CanExecute="BlockTheCommand"/>
   </RichTextBox.CommandBindings>

    protected void BlockTheCommand(object sender,
         CanExecuteRoutedEventArgs e)
    {
         e.CanExecute = false;
         e.Handled = true;
    }

You could then create custom command bindings for what you want to allow using something like what is shown here: http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings-and-custom-commands

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文