Getting information about the dragged object and the DragTarget

Jun 23, 2009 at 2:34 PM

hi kev,

great work but im having some problems to build the app i want.

i need a pool of items(rects) with different names and another pool with targets. after dragging everything to the right place a button will be clicked and within the click event i need the information wich item is provided in which target.

is this possible?

with best regards

Coordinator
Jun 24, 2009 at 8:29 AM

Hello abaumann,

 

every droptarget has a content-property which contains a dragsource - you should be able to run through your droptargets and check their dragsources to get the info you want.

 

Kind regards,

Kev.

Jun 24, 2009 at 9:42 AM

thank you kev, my query is working now.

but i thought about the case i need it for and maybe i need another solution.

i want to build up a container with some items, itemsize belongs to the stock. now i want to drag item1 to a droptarget, a popup with the amount comes up. after you confirmed the amount it will be substracted in the source and added to the target

do you maybe know whats the best practice to build a case like that?

regards

Coordinator
Jun 24, 2009 at 3:01 PM

Hi,

well, if I understand correctly, you're actually trying to do something with the data your controls are bound to, not with the dragsource/droptargets, right?  If that's the case, you can manipulate the data you want in the dropped-events.  If you've implemented INotifyPropertyChanged etc on your data classes, the UI will automatically get updated.  

If this is what you want, you might want to download the latest source code drop: it includes features that aren't in the released version, like a DropMode property (defines what happens when you drop a drag source on a drop target: you can choose to actually drop (and thus move) the drag source, or you can choose to let the drag source return to where it originated from.  Useful in scenarios where you want to drop an item somewhere and execute actions when it's dropped, but do not want it to move, for example: a colour swatches window where you can drag the colours onto an element, give the element the colour that's been dragged onto it, but put the colour element itself back onto the swatches window), and an AllowAnyDropTarget property (when set to true, any drop target will be valid for this drag source.  Useful in scenarios with dynamic droptarget generation (like droptargets in a listbox, for example)).

 

With kind regards,
Kev. 

Jun 29, 2009 at 8:32 AM
Edited Jun 29, 2009 at 9:32 AM

thank you for your help, i checked out the release today but i have a problem to find the right event.

i thought DragSourceDropped would do it for me, but the handler does not fire when i drop my item into

AllowAnyDropTarget and ReturnDragSourceMode are really nice but i need an event that is raised when i drop an item into the target to get information which item from which source to which target is dropped. is this possible?

 

edit: DragSourceDropped seems to be the right event, but with return to source enabled the content of the target isnt set to the dragsource :/

 

 

Coordinator
Jul 2, 2009 at 2:03 PM

Hello abaumann,

 

I'm afraid that is expected behaviour... if you return the dragsource to its original position, the content of the target stays at what it was.  You should, however, be able to get info about the drag source that's being dropped - I'll look into it!