RichTextBox WPF中的UndoLimit和MenuConText [英] UndoLimit and MenuConText in RichTextBox WPF

查看:67
本文介绍了RichTextBox WPF中的UndoLimit和MenuConText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Xaml中设置了UndoLimit = 10。当我运行我的应用程序时:

I set UndoLimit =10 in Xaml. When i run my app:

在Richtextbox中,我输入10次,

In Richtextbox, I input 10 times,


  1. 如果我使用Ctrl + Z来撤消。我可以撤消10次。 
  2. 如果我通过rightClick打开ContextMenu,那么我使用Ctrl + Z来撤消。我只撤消了9次。 

有人告诉我为什么在打开ContextMenu后我可以撤消9次?

Someone tell me why I can undo 9 times after open ContextMenu ?

推荐答案



HI ThanhNT2,



>>如果我通过rightClick打开ContextMenu,那么我使用Ctrl + Z来撤消。我只撤消了9次。 

有人告诉我为什么打开ContextMenu后我可以撤消9次?



据我所知,当RichTextBox控件有焦点时,它有自己的撤销/重做处理。 RichTextBox Undo / Redo是一个内置命令。它将捕获控制触发的当前事件并检查操作,是否实现IAction并提供
两种方法:一种用于实际执行操作,另一种用于撤消它。



但是 您可以自己实施。



以下链接供您参考。



如何使用MVVM实现撤消/重做



通过WPF应用程序中的无状态命令栈实现撤消/重做(Sprint 1/4)




注意:此回复包含对第三方万维网站点的引用。 Microsoft提供此信息是为了方便您。 Microsoft不控制这些网站,也未测试在这些网站上找到的任何软件或信息;因此,
Microsoft不能就其中发现的任何软件或信息的质量,安全性或适用性做出任何陈述。使用互联网上的任何软件都存在固有的危险,微软提醒您在从互联网上检索任何软件之前确保您完全了解风险。 



最好的问候,



Yong Lu

HI ThanhNT2,

>>if i open ContextMenu by rightClick, then i use Ctrl+Z to undo. I just undo 9 times. 
Someone tell me why I can undo 9 times after open ContextMenu ?

As far as I know, When the RichTextBox control has focus, it has its own Undo/Redo handling. The RichTextBox Undo/Redo is a built-in command. It will capture the current events that control fires and check the action, whether it implements IAction and provides two methods: one for actually doing the stuff, and another for undoing it.

but  you can implement it by yourself.

the following links for your reference.

How to implement undo/redo using MVVM

Undo/Redo Implemented via Stateless Command Stacks in WPF Applications (Sprint 1/4)


Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet. 

Best Regards,

Yong Lu


这篇关于RichTextBox WPF中的UndoLimit和MenuConText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆