punker76 / gong-wpf-dragdrop

The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy function doesn't seem to work

MrBigDog2U opened this issue · comments

I need to be able to drag-copy from a listbox and drop into another listbox and the code seems to imply that this should be possible but it either doesn't work or I'm misunderstanding how it should work.

Using the "Bound ListBoxes" example, the lower ListBox indicates that holding the Control key should result in a drag-copy operation but it behaves exactly the same regardless of the state of the Control key - always moving from one list to another.

It looks like the moveData boolean expression in DefaultDropHandler.Drop is just wrong. It also appears that the drag-copy behavior is incompletely implemented in general. I made some changes that made the drag-copy operation behave a little more like I would expect but, when I dragged the copied item back to the source listbox, it duplicated it (I suppose that's a possible interpretation of what should happen but not at all intuitive).

@MrBigDog2U I'll fix this in the default drop handler by doing this

        var copyData = (dropInfo.DragInfo.DragDropCopyKeyState != default(DragDropKeyStates)) && dropInfo.KeyStates.HasFlag(dropInfo.DragInfo.DragDropCopyKeyState)
                       //&& (dropInfo.DragInfo.VisualSource != dropInfo.VisualTarget)
                       && !(dropInfo.DragInfo.SourceItem is HeaderedContentControl)
                       && !(dropInfo.DragInfo.SourceItem is HeaderedItemsControl)
                       && !(dropInfo.DragInfo.SourceItem is ListBoxItem);

for now, I don't know if we should prevent the copy action if target = source

I don't think that's right either. From this condition, if the SourceItem
is a ListBoxItem (or any of the other specified controls), then copyData
will be false regardless of the KeyStates. This means that you can never
copy a ListBoxItem.

My own expectations of what to do if (target == source) is that it would
never be a copy although I just checked Windows Explorer and, if you
ctrl-drag an item within a list in the right hand pane, it DOES do a copy.
So I don't know if preventing the copy on that condition is right either.

On Wed, Feb 3, 2016 at 8:01 AM, Jan Karger notifications@github.com wrote:

@MrBigDog2U https://github.com/MrBigDog2U I'll fix this in the default
drop handler by doing this

    var copyData = (dropInfo.DragInfo.DragDropCopyKeyState != default(DragDropKeyStates)) && dropInfo.KeyStates.HasFlag(dropInfo.DragInfo.DragDropCopyKeyState)
                   //&& (dropInfo.DragInfo.VisualSource != dropInfo.VisualTarget)
                   && !(dropInfo.DragInfo.SourceItem is HeaderedContentControl)
                   && !(dropInfo.DragInfo.SourceItem is HeaderedItemsControl)
                   && !(dropInfo.DragInfo.SourceItem is ListBoxItem);

for now, I don't know if we should prevent the copy action if target =
source


Reply to this email directly or view it on GitHub
#162 (comment)
.

the SourceItem is different to VisualSourceItem. this is directly ListBoxItem or TreeVieItem etc if you have an ItemsControl without ItemsSource binding. so copy this is limited for now, cause it's not an easy way to do this.

Von meinem iPhone gesendet

Am 03.02.2016 um 17:17 schrieb MrBigDog2U notifications@github.com:

I don't think that's right either. From this condition, if the SourceItem
is a ListBoxItem (or any of the other specified controls), then copyData
will be false regardless of the KeyStates. This means that you can never
copy a ListBoxItem.

My own expectations of what to do if (target == source) is that it would
never be a copy although I just checked Windows Explorer and, if you
ctrl-drag an item within a list in the right hand pane, it DOES do a copy.
So I don't know if preventing the copy on that condition is right either.

On Wed, Feb 3, 2016 at 8:01 AM, Jan Karger notifications@github.com wrote:

@MrBigDog2U https://github.com/MrBigDog2U I'll fix this in the default
drop handler by doing this

var copyData = (dropInfo.DragInfo.DragDropCopyKeyState != default(DragDropKeyStates)) && dropInfo.KeyStates.HasFlag(dropInfo.DragInfo.DragDropCopyKeyState)
//&& (dropInfo.DragInfo.VisualSource != dropInfo.VisualTarget)
&& !(dropInfo.DragInfo.SourceItem is HeaderedContentControl)
&& !(dropInfo.DragInfo.SourceItem is HeaderedItemsControl)
&& !(dropInfo.DragInfo.SourceItem is ListBoxItem);

for now, I don't know if we should prevent the copy action if target =
source


Reply to this email directly or view it on GitHub
#162 (comment)
.


Reply to this email directly or view it on GitHub.