在 WPF 中实现 ApplicationCommands.Copy?
我刚刚使用 Command = "ApplicationCommands.Copy"
创建了一个菜单,我认为我必须处理绑定的 Executed
事件,并添加一个绑定,但我只是不这样做不需要。
现在我很困惑!
这个命令的执行在哪里呢?它如何自动复制在窗口中的任何文本框中选择的文本?
谢谢!
I just created a menu with Command = "ApplicationCommands.Copy"
and I thought I had to handle the Executed
event of the binding, and add a binding but I just don't need to.
Now I'm confused!
Where is the implementation of this command? How can it automatically copy a text selected in any of the textboxes I have in my window?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您如何验证是否不需要处理命令的
Executed
事件 - 是否使用内置的TextBox
?如果是这样,您不必处理它的原因是因为TextBox
已经处理该命令(因为它是内置的)。对于其他编辑命令 - 剪切、粘贴、撤消、重做(可能还有其他命令)也是如此。如果您使用自己的自定义命令,那么您需要处理其
Executed
事件,如您在问题中所述。How did you verify that you didn't need to handle the
Executed
event of the command - was it with the built-inTextBox
? If so, the reason that you don't have to handle it is because theTextBox
handles that command already (since it is built-in). The same is true for the other edit commands - Cut, Paste, Undo, Redo (and probably others as well).If you were using your own custom command, then you would need to handle its
Executed
event, as you stated in your question.