Review the previous article: C# WPF: Drag the file in !!!

This article completes the corresponding sequel: "C# WPF: This time, drag the file out!"
Let's preview the effect:

The code for the above effect is very concise. In XAML, just register the event PreviewMouseLeftButtonDown:
<Grid MouseMove="Grid_MouseMove" AllowDrop="True" Drop="Grid_Drop" DragEnter="Grid_DragEnter" PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown">
The event handler code is as follows:
// Handling file drag-out operation
private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// Currently each menu consists of an Image and a TextBlock, so check if the dragged element is an Image control; ignore drags on other target controls.
var img = e.OriginalSource as Image;
if (img == null || img.Tag == null)
{
return;
}
var menuInfo = img.Tag as MenuItemInfo;
if(menuInfo==null)
{
return;
}
#region Drag code
ListView lv = new ListView();
string dataFormat = DataFormats.FileDrop;
DataObject dataObject = new DataObject(dataFormat, new string[] { menuInfo.FilePath});
DragDropEffects dde = DragDrop.DoDragDrop(lv, dataObject, DragDropEffects.Copy);
#endregion
}
The key part is the latter code (Drag code, source repository path). You need to pass the original file path via the DragDrop.DoDragDrop method, and the operating system handles the file copy operation.
The above operation is still quite simple; it essentially just performs a file copy at the operating system level. To implement a drag-and-drop download feature similar to Baidu Netdisk (as shown below):

For the above functionality, the program actually needs to do quite a bit. It must monitor the drop path, and once the drop path is obtained, the file can be downloaded via the original network path. It is recommended to read this article, which references drag-and-drop file download operations: WPF Drag and Drop Files (drag in and drag out), monitor the location where the file is dropped, similar to Baidu Netdisk drag and drop.
Additionally, this article on WPF drag-and-drop is also well-written; it is recommended to read: DragDrop drag-and-drop examples in WPF.