I want go get value from 'd' IDataObject to 'c' IDataObject in C# but my 'c' possess value from my Clipboard even when i won't click D key. How can I give independent value from one IDataObject to second?
First function:
if (Keyboard.IsKeyDown(Key.D))
{
d = Clipboard.GetDataObject();
c = d; // <-- doesn't work
string dd = d.GetData(DataFormats.Text).ToString(); //content
MessageBox.Show(dd);
}
Second function
if (Keyboard.IsKeyDown(Key.S))
{
string dd = c.GetData(DataFormats.Text).ToString(); //content
MessageBox.Show(dd);
}
Why do you need a backup of
IDataObject
?If it was possible in all cases it would look like this
Backup
Then you may use it as local data storage. For example in case you want to change
Clipboard
, use the changed value e.g. paste it into some application and the restore the previous data toClipboard
.Restore
But in your case that's a simple
string
. You may do it this way: