InlineUIContainer 的问题
我在 RichTextBox 中有一个 Windows.Documents.InlineUIContainer,有时当我按下 Ctrl+Space 等组合键时,对齐的字体大小会发生变化。我找不到任何地方来处理这些事件并以某种方式阻止它们。我不想在 RichTextBox 中阻止它。我更寻找一种仅在 InlineUIContainer 上阻止它的方法。
I have an Windows.Documents.InlineUIContainerin a RichTextBox, and sometimes it's font size of alignment change when I hit key combination such as Ctrl+Space. I couldn't find any place to handle these events and block them somehow. I don't want to block it in the RichTextBox. I am more looking for a way to block it only on the InlineUIContainer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
InlineUIContainer 是一个 FrameworkContentElement,因此它参与所有正常的事件路由。因此,要阻止命令路由,需要在 InlineUIContainer 上使用
CommandManager.AddExecutedHandler
(或等效的AddHandler(CommandManager.ExecutedEvent)
),并将命令标记为已处理。或者,如果这样做更容易,则可以将相同的处理程序添加到内联 UI 内容 (InlineUIContainer.Content)。
请注意,上述代码会阻止所有 EditingCommands,但您可以根据需要阻止任何其他命令。
InlineUIContainer is a FrameworkContentElement, so it participates in all the normal event routing. So to block command routing need to do is use
CommandManager.AddExecutedHandler
(or equivalentlyAddHandler(CommandManager.ExecutedEvent)
) on the InlineUIContainer and mark the commands as Handled.Alternatively the same handler can be added to your inline UI content (InlineUIContainer.Content) if it easier to do it that way.
Note that the above code blocks all EditingCommands, but you can block any other commands as desired.