且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

UWP/WinRT:如何在 TextBox 上启用撤消挂钩?

更新时间:2021-08-14 22:40:23

您绝对可以通过 TextChanged 事件手动记录历史记录.撤消命令用于显示之前的输入.似乎无法连接到控件.

You definitely can record the history manually by TextChanged event. Undo command is used to display the previously input. Hook into the control seems not possible.

处理来自文本框的 ContextMenuOpening 事件,您可以通过您自己的命令修改弹出窗口,例如您自己的撤消/重做历史记录.

Handle the ContextMenuOpening event from TextBox and you can modify the Popup by your own commands, for example your own undo/redo history.

一个很好的示例:https://code.msdn.microsoft.com/windowsapps/Context-menu-sample-40840351 也适用于 UWP.

A good sample: https://code.msdn.microsoft.com/windowsapps/Context-menu-sample-40840351 also works fine with UWP.