I have been working on a WPF Application that is essentially a WYSIWYG editor, and is using drag and drop functionality. I have the drag and drop functionality working, but need to make it more intuitive and user friendly. Part of this will involve actually showing the item being dragged. What is the easiest way to do this? The items I am dragging are nothing really special,but I am not even sure where to look for how to do this.
You will need to make use of DragDrop.GiveFeedback amongst other things.
Trivial example from an older blog post in dealing with cursor manipulation...
private void StartDragCustomCursor(MouseEventArgs e)
{
GiveFeedbackEventHandler handler = new GiveFeedbackEventHandler(DragSource_GiveFeedback);
this.DragSource.GiveFeedback += handler;
IsDragging = true;
DataObject data = new DataObject(System.Windows.DataFormats.Text.ToString(), "abcd");
DragDropEffects de = DragDrop.DoDragDrop(this.DragSource, data, DragDropEffects.Move);
this.DragSource.GiveFeedback -= handler;
IsDragging = false;
}
void DragSource_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
try
{
//This loads the cursor from a stream ..
if (_allOpsCursor == null)
{
using (Stream cursorStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
"SimplestDragDrop.DDIcon.cur"))
{
_allOpsCursor = new Cursor(cursorStream);
}
}
Mouse.SetCursor(_allOpsCursor);
e.UseDefaultCursors = false;
e.Handled = true;
}
finally { }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With