Reputation: 1543
I'm handling drag and drop events in a TreeView using PreviewMouseDown, PreviewMouseMove and PreviewMouseUp, however, there is an issue.
In my PreviewMouseDown handler, I set everything ready in case there's a drag started (detected in the Move event), however I set e.Handled = true. This means that standard selection events don't get generated on my tree!
What I want to be able to do in my Up event is to invoke the standard treeview selection changed event - except I cannot call events outside of the tree. So what's the correct way to do this?
I have tried using the standard MouseDown, MouseMove and MouseUp events however there's an issue with messing up my multiple selection feature that means I need to use the Preview version of those events.
Upvotes: 1
Views: 1533
Reputation: 1543
My solution to this is to not use the Preview handlers, instead I use MouseDown, MouseMove and MouseUp.
The sequence of events is:
* MouseDown (set up for possible drag)
* SelectionChanged (remember any selection change)
* MouseMove (here we might go into a drag operation)
* MouseUp (if we went into a drag operation, all done, otherwise process the multiple selection stuff)
Upvotes: 1