简体   繁体   中英

MVVM Catch Cut, Copy, and Paste Textbox Event

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.

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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM