Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It is possible to drag items from the W10 Menu Start to the desktop. I assume the resulting shortcuts for UWP apps are Uri's but with another protocol then HTTP or HTTPS.
Modern Apps - Launch Other Applications from Your UWP App[^]

I want to drag and drop directly into a WPF/C# program. How do I process the dropped Data, e.g. on what dataformat I have to test and to what datatype I have to convert?

What I have tried:

private void myListBoxItem_Drop(object sender, DragEventArgs e)
{
foreach (string format in e.Data.GetFormats()) Console.WriteLine(format);

// result when dropping UWP item from W10 Menu start:
// [0]: "Shell IDList Array"
// [1]: "FileDrop"
// [2]: "FileNameW"
// [3]: "FileName"
// [4]: "FileContents"
// [5]: "FileGroupDescriptorW"
// [6]: "Preferred DropEffect"

// This is a method to process standard dropped files
if (e.Data.GetDataPresent(DataFormats.FileDrop))
string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);

// result in error
// System.Runtime.InteropServices.COMException
// HResult=0x80070490
// Message=Kan element niet vinden. (=Can't find element)
// Unable to create CF_HDROP from storage items.
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900