DataPackage.SetDataProvider's documentation states:
Use the SetDataProvider method when your app ... does not want to
supply the data until the target app requests it.
But when I run the following code it calls the callback method immediately.
static void CopyToClipboardReference(string s)
{
DataPackage dataPackage = new DataPackage();
reference = s;
dataPackage.SetDataProvider(StandardDataFormats.Text, CopyToClipboardAction);
Clipboard.SetContent(dataPackage);
}
static string reference;
static void CopyToClipboardAction(DataProviderRequest request)
{
//Called immediately!
request.SetData(reference);
}
When I change StandardDataFormats.Text
to StandardDataFormats.Html
it does work as expected (delayed rendering) but then I don't get an option for 'Paste' in applications such as Notepad.
How do I get it to wait for text until it's called from a target app as it is supposed to do according to its documentation?
Additionally:
The DataTransfer.OperationCompleted event is not raised.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…