wpfdrag-and-dropvisualbrush

Is It Possible To Create A Cursor In WPF From a VisualBrush?


I'm doing some Drag and Drop operations, and I want to use a visual copy of the element I'm dragging for the cursor. It's easy enough to get a VisualBrush of the element, but I have no idea how to turn this into a cursor.

I've read the Jamie Rodriguez blog posts, but his solution isn't quite what I'm looking for because he essentially wires things up to a "global" GiveFeedback event (his DragSource). I'd rather just take the image from the VisualBrush and make that the cursor. Is that possible?


Solution

  • Usually (both in the example you linked and in this example by Bea Stollnitz) this is done with an Adorner.

    If you really wanted to change the Cursor itself, you'd have to construct a .cur file in memory and stream it into the Cursor constructor. I've never done this and I don't recommend it, but I think it should be possible.