From the course: Windows Presentation Foundation: 3 Events and the Event Model
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Use DragEnter to indicate a valid drag target
From the course: Windows Presentation Foundation: 3 Events and the Event Model
Use DragEnter to indicate a valid drag target
- [Instructor] At this point in my application, I've got the initial drag operation started, so I can pick one of these images and I can drag it over, but there's no visual indication to the user that this image is a target that they can drop here, so let's fix that. First thing to do is pick your targets. You can have any of your elements be a target, and you have to specify a setting on the target itself. It's called the AllowDrop property. Set that the true, then I'll re-run the application and see if there's any difference. We'll pick up this pastry image, and as I move into the element that I've marked as AllowDrop, you'll see that the cursor automatically changes, so WPF framework is providing this feedback to the user. If this is all you need then you can stop here and go on and write the drop code, but there could be times when you want to change the cursor, maybe pick a different cursor than this one, or maybe you want to have some sort of other visual feedback, so that's…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
The MouseEnter and MouseLeave events2m 26s
-
Use the MouseWheel event2m 55s
-
Use the MouseMove event6m 19s
-
Set the mouse cursor2m 2s
-
Start a drag operation7m 24s
-
Use DragEnter to indicate a valid drag target2m 20s
-
Use the Drop event to complete the drag/drop operation2m 34s
-
Use formats to send different data to the drop target3m 39s
-
-
-