简体   繁体   中英

Setup ListView as a drop target for files on Windows 10 Universal Apps

I have declared in my XAML the following element:

<ListView Name='mPlaylist' AllowDrop='True' DragEnter='HandlePlaylist_DragEnter' Drop='HandlePlaylist_Drop' />

When I drag a file from Windows Explorer or the desktop onto my ListView using the mouse , the DragEnter handler is executed and I can set the AcceptedOperation member of the DragEventArgs to Link (and Handled to true). So far, so good.

When I release left click, the Drop event handler is never fired. I can't figure out why not.

When I drag a file over the ListView, the cursor changes to a stop/invalid cursor, and the file thumbnail is overlaid with a red cross (despite my setting the AcceptedOperation to match one of the RequestedOperations - Link).

Although likely unrelated, the thumbnail also jumps up and to the left, a fair distance from the cursor. Moving the cursor over the ListView and the thumbnail does not maintain a constant distance from the cursor - I haven't been able to figure that out either.

I'm working on the PC, and using version 10.0.10069.0 of the Universal app platform in VS2015 RC.

Any ideas on what I can do to cause the Drop event to fire on my ListView (and perhaps even fix the visual glitch of the thumbnail 'separating' itself from the cursor when over the ListView) would be very much appreciated.

Solution is to use the DragOver event to set the AcceptedOperation member of the DragEventArgs, rather than DragEnter.

Thanks to Igor Ralic for posting the solution on his blog .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM