How to capture drag and drop events

0 Answers 3 Views
Dock
Mark
Top achievements
Rank 1
Iron
Iron
Mark asked on 27 May 2025, 02:28 PM

Is there a way to capture an event after a Dock has been dragged or dropped (either to a new position in an existing DockZone, or to a different DockZone)? 

The use case i've developed is a query / expression builder where each dock is a custom user control representing a single condition in a query.  Drag and drop is enabled in the DockZone so that docks can be re-arranged as necessary.  This all works great and i'm able to create docks at runtime and populate each dock with the correct expression data from a database.  However there are certain display items in the dock's user control that i would like to be able to manipulate based on the dock's position in the DockZone.  For example, if you were building a query with two expressions you need to be able to join those two expressions together using either AND, or OR.  If there is only a single expression in your query then selecting AND or OR isn't necessary because there is nothing to combine.  So in my solution  when the first dock in a zone is configured it doesn't ask for or show any AND/OR options because it's not applicable.  It's only applicable for docks in the 2nd, 3rd, 4th+ positions. This all works great until you have re-order the conditions.  When the conditions are re-ordered if the first condition is swapped into the second position, then ideally i'd like to be able to capture some event or tie into some command so that i can re-draw the docks so that i can show/hide this logic operator selector (and/or).   

Currently it looks like this before you drag and drop: You can see the AND/OR value is not displayed next to the first condition (dock). 

  After dragging to just swap the position of these two docks it looks like this:

If the user were to save this state to the database, it would re-draw everything correctly, for the most part:

The AND/OR  selector is dropped from the first expression and it is visible next to the second condition even though it says AND instead of previously being OR.  The user can correct for this AND/OR in the second condition if they can see that it needs to be switched.  If they don't see anything (as in screenshot 2) then they don't know that anything needs to be adjusted. 

Ideally i'd like to be able to get the user to this third screenshot without the user having to click a save button after each drag and drop operation.  I tried to use the PositionChanged event but the dock state that is present in this event handler is the pre-move state, not the post-move state.  Ideally i'd want to re-draw all the docks because like in this example dragging one dock to a different position should change the display in two docks.  In a more complicated scenario a dock could even be dragged to a separate DockZone (which is not covered in this example), so to be safe i'd like to be able to redraw / create all the docks across all the zones whenever any individual dock is dragged and dropped.  

Is this possible?  Thanks for your suggestions!

-Mark

No answers yet. Maybe you can help?

Tags
Dock
Asked by
Mark
Top achievements
Rank 1
Iron
Iron
Share this question
or