在 WPF 中实现 ApplicationCommands.Copy?

发布于 2024-08-30 15:18:08 字数 201 浏览 0 评论 0原文

我刚刚使用 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 技术交流群。

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

发布评论

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

评论(1

私藏温柔 2024-09-06 15:18:08

您如何验证是否不需要处理命令的 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-in TextBox? If so, the reason that you don't have to handle it is because the TextBox 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.

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