How can I drag-and-drop virtual files that are created after the drop, from a UWP app?

Viewed 250

I'm writing a UWP app that supports dragging virtual files to the Windows Shell. The files are sometimes big. So I don't want to start downloading and processing the content until the file is dropped (or pasted). Legacy desktop apps could do this by implementing CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS clipboard formats. Is there any way to get similar functionality from a UWP app?

What I've Tried

I know that UWP has a nifty way to drag-and-drop files to the shell, but I can't find a way to delay file creation until the drop. In the example below, the delayed data provider gets called immediately when the file drags over Windows Explorer.

private void GridView_DragItemsStarting(object s, DragItemsStartingEventArgs e)
{
    e.Data.SetDataProvider(StandardDataFormats.StorageItems, async (DataProviderRequest request) =>
    {
        //This code runs immediately when file gets dragged over the Windows shell.
    });
}

I have also experimented with StorageFile.ReplaceWithStreamedFileAsync() but again, the whole file is requested immediately before the file is dropped. Is there a way to delay the data request until after the file is dropped?

This problem is even worse when I try to copy a virtual file to the clipboard. The file data is immediately requested.

0 Answers
Related