MVVM捕获剪切,复制和粘贴文本框事件

时间:2023-01-20 17:35:56

I've looked all over for a good solution on this, but nothing is helping.What I need is listen for for cut, copy, and paste events and be able to manipulate the data in the clipboard. I think one path could possibly be a dependency property, but how could I implement this on a textbox using User Control? Any help with this would be appreciated.

我一直在寻找一个很好的解决方案,但没有任何帮助。我需要的是监听剪切,复制和粘贴事件,并能够操纵剪贴板中的数据。我认为一条路径可能是依赖属性,但是如何使用User Control在文本框中实现它呢?任何帮助都将不胜感激。

1 个解决方案

#1


0  

From your question I think you’re looking for setting/getting the text to/from the clip board.

根据您的问题,我认为您正在寻找设置/从剪辑板获取文本。

You can use the Clipboard.SetText(stringObj) or Clipboard.GetText() for your requirement. It belongs to the System.Windows namespace. You can read more it in in msdn - https://msdn.microsoft.com/en-gb/library/ms597043.aspx

您可以根据需要使用Clipboard.SetText(stringObj)或Clipboard.GetText()。它属于System.Windows命名空间。您可以在msdn中阅读更多内容 - https://msdn.microsoft.com/en-gb/library/ms597043.aspx

If you want to copy text from a textbox to clipboard at any time,

如果要随时将文本从文本框复制到剪贴板,

 Clipboard.SetText(txtBoxName.Text);

Whenever you want to access data copied in clipboard

每当您想要访问剪贴板中复制的数据时

 Clipboard.GetText();

#1


0  

From your question I think you’re looking for setting/getting the text to/from the clip board.

根据您的问题,我认为您正在寻找设置/从剪辑板获取文本。

You can use the Clipboard.SetText(stringObj) or Clipboard.GetText() for your requirement. It belongs to the System.Windows namespace. You can read more it in in msdn - https://msdn.microsoft.com/en-gb/library/ms597043.aspx

您可以根据需要使用Clipboard.SetText(stringObj)或Clipboard.GetText()。它属于System.Windows命名空间。您可以在msdn中阅读更多内容 - https://msdn.microsoft.com/en-gb/library/ms597043.aspx

If you want to copy text from a textbox to clipboard at any time,

如果要随时将文本从文本框复制到剪贴板,

 Clipboard.SetText(txtBoxName.Text);

Whenever you want to access data copied in clipboard

每当您想要访问剪贴板中复制的数据时

 Clipboard.GetText();