It is critical to provide visual feedback during the drag operation so that the user knows when a drop is available. This tutorial looks at the AllowDrop property and the DragEnter and DragLeave events.
- [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 what I'll do here.…And I'll work with the DragEnter event…
- Understanding routed events and event signatures
- Wiring up event handlers
- Event bubbling and tunneling
- Programming mouse events
- Programming keyboard and ink events