DragDropEffect.Copy Resets itself to None

1k views Asked by At

I have a ScatterViewItem in the Scatterview, whose manipulation is not handled by me. I also have a RichTextBox in the ScatterView, with property AllowDrop = True.

By default, the RichTextBox's DragEnter event fires whenever the ScatterViewItem is drag into it, which is correct. I checked DragDropEffect here, and it's DragDropEffect.Move. The Drop event fires appropriately after that.

I changed the DragDropEffect from Move to Copy in DragEnter, but the Drop event no longer fires. I checked the DragDropEffect again in DragOver and it somehow became None. I tried setting it in DragOver to Copy (again) but each time it will just become None by itself on the next trigger of DragOver.

The only time Drop event will fire is if DragDropEffect is set to All or Move. How do I change it to DragDropEffect.Copy and still fire the Drop event? I did set e.Handled = true after setting to DragDropEffect.Copy.

EDIT: My apologises, I did manipulate the svi's drag and drop a little. In the ScatterView's OnManipulationStarted, I get the svi and called svi.BeginDragDrop(svi.DataContext). That's all I did to the svi.

1

There are 1 answers

3
Sheridan On BEST ANSWER

What is the (DragEventArgs).AllowedEffects property value? You can only set the (DragEventArgs).Effects property to one of the values specified by the (DragEventArgs).AllowedEffects property. If DragDropEffects.Copy is not an option found in the (DragEventArgs).AllowedEffects property enumeration, then you will not be able to use that function.

You can set that option when you create your data object and call DoDragDrop:

DragDrop.DoDragDrop(item, dragData, DragDropEffects.All);

UPDATE >>>

As I said, normally, you set the allowable DragDropEffects enumeration when you call DoDragDrop... after seeing that you have called the SurfaceDragCursor.BeginDragDrop method, I looked online at the SurfaceDragDrop.BeginDragDrop Method page at MSDN and found this:

public static SurfaceDragCursor BeginDragDrop (
    FrameworkElement dragSource,
    FrameworkElement draggedElement,
    FrameworkElement cursorVisual,
    Object data,
    IEnumerable<InputDevice> inputDevices,
    DragDropEffects allowedEffects
)

I'm guessing that the last parameter here is where you set the DragDropEffects allowable effect enumeration.